Extension pandas dtype and array for physical units
This python package extends the popular data science library pandas with the physical units of the astrophysics library astropy. The package is compatible with modern pandas, although some features are only working with pandas version 3.0 or an upcoming pandas release.
History
Originally created for PyCon CZ 2019 (and later BI Fórum Budapest / PyData Cambridge the same year) by Jan Pipek. Updated to be compatible with modern pandas since 2025 by Julian Harbeck during the RACCOON project at Technische Universität Berlin.
Installation
pip install pandas-units-extensions
For development:
pip install -e .
Examples
>>> import pandas as pd
>>> import pandas_units_extension as pue
>>> 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")
0 68.0 deg_F
1 71.6 deg_F
2 87.8 deg_F
3 60.8 deg_F
Name: temperature, dtype: unit[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()
0 3.333333333333334 m / s
1 3.333333333333334 m / s
2 3.0555555555555554 m / s
3 2.7777777777777777 m / s
dtype: unit[m / s]
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.
Metadata
Release files for pandas-units-extension 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pandas_units_extension-0.2.1.tar.gz | 51.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pandas_units_extension-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.6 kB
Release files / pandas_units_extension-0.2.1.tar.gz
| Download URL | pandas_units_extension-0.2.1.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
beedef6b2bf890efdd43cec049382f4a0df388ee9f07c50d24fcd9ca55e6bdcc
|
|
BLAKE2b-256 checksum How to use checksums |
5cc54e66b76105d04f236a83628c0a423efa08435874038a5b4b75f441df9aec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pandas_units_extension-0.2.1-py3-none-any.whl
| Download URL | pandas_units_extension-0.2.1-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bdd2ce5ef18e40251fe5df473e7adeccbcbb2f41c8575d9da8d42eb1f66073f
|
|
BLAKE2b-256 checksum How to use checksums |
e69c4ffaa1dbfc4d19bf5403eb1279d9a989a2cdff0179ff0ff7ab3221ce2552
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for pandas-units-extension 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.