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.1.tar.gz (51.0 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.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pandas_units_extension-0.2.1.tar.gz
Algorithm Hash digest
SHA256 beedef6b2bf890efdd43cec049382f4a0df388ee9f07c50d24fcd9ca55e6bdcc
MD5 609ead04cf87bb3a8d5130970d9fac4c
BLAKE2b-256 5cc54e66b76105d04f236a83628c0a423efa08435874038a5b4b75f441df9aec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pandas_units_extension-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bdd2ce5ef18e40251fe5df473e7adeccbcbb2f41c8575d9da8d42eb1f66073f
MD5 64282a3ce9fd706f8a0903980b9fa106
BLAKE2b-256 e69c4ffaa1dbfc4d19bf5403eb1279d9a989a2cdff0179ff0ff7ab3221ce2552

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