Extension pandas dtype and array for physical units.
Project description
Extension pandas dtype and array for physical units
Warning: Not fully compatible with pandas yet, especially not so for 1.0. Some operations may or may not work, while common ones should.
History
Originally created for PyCon CZ 2019 (and later BI Fórum Budapest / PyData Cambridge the same year).
Installation
pip install pandas-units-extensions
For development:
pip install -e .
Examples
import pandas as pd
import pandas_units_extension as _
temps = pd.DataFrame({
"city": ["Prague", "Kathmandu", "Catania", "Boston"],
"temperature": pd.Series([20, 22, 31, 16], dtype="unit[deg_C]")
})
temps["temperature"].units.to("deg_F")
...
df = pd.DataFrame({
"distance": pd.Series([10, 12, 22, 18], dtype="unit[km]"),
"time": pd.Series([50, 60, 120, 108], dtype="unit[min]")
})
speed = df["distance"] / df["time"]
speed.units.to_si()
See doc/units.ipynb for more.
Links
- https://www.astropy.org/
- https://pint.readthedocs.io/en/0.10.1/pint-pandas.html - Another library supporting units inside pandas.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pandas-units-extension-0.1.0.tar.gz
.
File metadata
- Download URL: pandas-units-extension-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32c967ab022890d7ac991b153ce840f6a309feae7c7d668a4467662605e4865f |
|
MD5 | 7f78c3333f768f3796ce51f738bb3891 |
|
BLAKE2b-256 | 83153518e57086d15d414c48fc39bc73979dc7a8816a8cb2f2b68d69e9dad2aa |