--- id: pint-xarray version: "0.6.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # pint-xarray — Physical units interface to xarray using Pint License: permissive · Maintenance: active · Downloads: 113.3K/mo ## What it is and what it does pint-xarray bridges Pint's physical units library with xarray's labeled multidimensional arrays, letting you attach and track units on dataset variables and perform unit-aware arithmetic and conversions. It works by registering accessor methods on xarray objects, so you call `.pint.quantify()` to add units, `.pint.to()` to convert between units, and `.pint.dequantify()` to strip units back off. The package is designed for scientific and engineering workflows where dimensional consistency matters—tracking whether a measurement is in meters or kilometers, seconds or milliseconds—and catching unit mismatches before they propagate through calculations. It integrates directly with xarray's data model, so units stay attached to variables as you slice, combine, or transform datasets. Use it for: - Attach units to climate or weather model output and convert between unit systems for analysis. - Track physical dimensions through geophysical data processing pipelines to catch unit errors early. - Perform dimensional analysis on scientific datasets to ensure unit consistency across operations. - Convert measurement data from one unit system to another while preserving xarray's labeled structure. - Build unit-aware data pipelines for physics or engineering simulations using xarray as the data container. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds physical units support to xarray datasets and data variables using Pint, enabling unit-aware arithmetic and conversions on multidimensional labeled arrays. Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and fills a genuine gap for scientists and engineers working with xarray who need physical units. The Apache-2.0 license is permissive. Start with it if you're already using xarray and need dimensional tracking; the API is straightforward and the dependency footprint is small. ## Install pip install pint-xarray uv add pint-xarray poetry add pint-xarray ## Installing pint-xarray Before you install: Low friction installation with a pure-Python wheel. Actively maintained as of 2026-08-14 with recent releases; depends on three well-established packages (xarray, numpy, pint) that are standard in scientific Python. License in practice: Apache-2.0 permissive license allows commercial and private use with minimal restrictions, making it safe for most projects. Quickstart: pip install pint-xarray import pint_xarray import xarray as xr ds = xr.Dataset({"a": ("x", [0, 1, 2]), "b": ("y", [-3, 5, 1], {"units": "m"})}) q = ds.pint.quantify(a="s") c = q.pint.to({"a": "ms", "b": "km"}) Requires Python 3.11 or later. Verify before relying: - Whether unit-aware operations preserve xarray's lazy evaluation and chunking (Dask integration). - Performance impact of unit tracking on large multidimensional arrays. - Compatibility with xarray's groupby, resample, and other high-level operations when units are attached. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 113.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags xarray units, pint xarray integration, physical units for arrays, unit conversion xarray, dimensional analysis xarray, quantity arrays, scientific data units, units-and-quantities, scientific-computing, data-validation [View on SkillFed](https://skillfed.io/packages/pint-xarray) · [View on PyPI](https://pypi.org/project/pint-xarray/)