Skip to main content

Extension pandas dtype and array for physical units and quantities from astropy.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_units_extension-0.2.0.tar.gz (50.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_units_extension-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pandas_units_extension-0.2.0.tar.gz.

File metadata

  • Download URL: pandas_units_extension-0.2.0.tar.gz
  • Upload date:
  • Size: 50.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pandas_units_extension-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ea410e55a1da9837269f14053196339010596ef0a5e7c163b318fda46e1a83a5
MD5 25de039c3ea94da1ff8adf0bfa0064ce
BLAKE2b-256 f86acd8c70fce0a503a158c402f7a4fd7a4cf388e02a561a955c7610612c2f09

See more details on using hashes here.

File details

Details for the file pandas_units_extension-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pandas_units_extension-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7d8fa5db505aa6b0084b7abac252fbeed33c9f6ba8b31382e3f70a999a3c316
MD5 d899914091a74146bbe9da9e4f1020f3
BLAKE2b-256 b3343c3ba6160e03512b52f3bdfd45eca8beeae6cb3bada89cdfb56ca522d1bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page