pint-xarray
A convenience wrapper for using pint with xarray.
Usage
To convert the variables of a Dataset to quantities:
In [1]: import pint_xarray
...: import xarray as xr
In [2]: ds = xr.Dataset({"a": ("x", [0, 1, 2]), "b": ("y", [-3, 5, 1], {"units": "m"})})
...: ds
Out[2]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) int64 0 1 2
b (y) int64 -3 5 1
In [3]: q = ds.pint.quantify(a="s")
...: q
Out[3]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) int64 [s] 0 1 2
b (y) int64 [m] -3 5 1
to convert to different units:
In [4]: c = q.pint.to({"a": "ms", "b": "km"})
...: c
Out[4]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 [ms] 0.0 1e+03 2e+03
b (y) float64 [km] -0.003 0.005 0.001
to convert back to non-quantities:
In [5]: d = c.pint.dequantify()
...: d
Out[5]:
<xarray.Dataset>
Dimensions: (x: 3, y: 3)
Dimensions without coordinates: x, y
Data variables:
a (x) float64 0.0 1e+03 2e+03
b (y) float64 -0.003 0.005 0.001
For more, see the documentation
Metadata
Release files for pint-xarray 0.6.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 | |
|---|---|---|---|
| pint_xarray-0.6.1.tar.gz | 57.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pint_xarray-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 101.8 kB
Release files / pint_xarray-0.6.1.tar.gz
| Download URL | pint_xarray-0.6.1.tar.gz |
|---|---|
| Size | 57.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0febf909b69342fde39b8e053875c52bb75a65e4fc56d95bd146f74449aed84
|
|
BLAKE2b-256 checksum How to use checksums |
a192b402b6e58a4f9ea2718ada67171586dc2ebd494ffcaf0c08f2b634714ad5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.
Transparency logRelease files / pint_xarray-0.6.1-py3-none-any.whl
| Download URL | pint_xarray-0.6.1-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f96682bda1234c3be652db2f9b7cfb8d858cc870c8e7a51213163e743d8ccf7
|
|
BLAKE2b-256 checksum How to use checksums |
f40de20fbbf036a88fc7be7438f6fc1c7606e8806064f933f7eb6d4f110bc622
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.
Transparency log