https://github.com/janpipek/pandas-units-extension
Units extension array for pandas based on astropy
https://github.com/janpipek/pandas-units-extension
Last synced: 4 months ago
JSON representation
Units extension array for pandas based on astropy
- Host: GitHub
- URL: https://github.com/janpipek/pandas-units-extension
- Owner: janpipek
- License: mit
- Created: 2020-01-11T16:11:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-01T10:18:12.000Z (over 6 years ago)
- Last Synced: 2025-10-11T05:37:32.700Z (8 months ago)
- Language: Python
- Size: 42 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```bash
pip install pandas-units-extensions
```
For development:
```bash
pip install -e .
```
## Examples
```python
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](doc/units.ipynb) for more.
## Links
-
- - Another library supporting units inside pandas.