xarray
N-D labeled arrays and datasets in Python
What it is and what it does
xarray is a Python library that layers dimension names, coordinates, and metadata on top of NumPy arrays to make working with multi-dimensional scientific data more intuitive and less error-prone. Instead of tracking array shapes and indices manually, you name dimensions and select data by label—similar to how pandas works for tabular data but extended to arbitrary numbers of dimensions. It was originally developed at The Climate Corporation for climate and geospatial work and is now a NumFOCUS fiscally sponsored project.
The library is particularly well-suited for netCDF files and integrates with pandas and NumPy. Core operations include selecting data by coordinate labels, performing reductions over named dimensions, aligning datasets with automatic handling of missing values, and groupby-style split-apply-combine workflows. It ships with a large set of domain-agnostic analytics and visualization functions. The package depends only on numpy, packaging, and pandas—all production-grade libraries—and installs as a pure Python wheel with low friction.
Use it for:
- Load and manipulate netCDF climate or weather datasets with time and spatial dimensions labeled by date and location.
- Perform time-series analysis by selecting and aggregating data over named time dimensions without manual index arithmetic.
- Align and combine multiple multi-dimensional datasets on shared coordinate labels, handling missing values automatically.
- Build scientific data pipelines where dimension names make operations self-documenting and reduce indexing bugs.
- Integrate with pandas for tabular analysis and with external tools for parallel computation on large gridded datasets.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
xarray adds dimension, coordinate, and attribute labels to NumPy-like arrays, enabling intuitive operations on multi-dimensional data by name rather than integer position.
Yes. xarray is a mature, actively maintained library with no known vulnerabilities, permissive Apache-2.0 licensing, and low install friction. It solves a real problem—making multi-dimensional array operations less error-prone—and is widely used in scientific computing. Install it if you work with labeled multi-dimensional data, netCDF files, or climate and geospatial datasets.
Install
xarray on PyPI
pip
pip install xarrayuv
uv add xarraypoetry
poetry add xarrayInstalling xarray
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance with a recent release and ongoing commits. Depends only on numpy, packaging, and pandas—all widely used, stable libraries.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions. Bundles code from pandas, NumPy, Seaborn (BSD), CPython (PSF), and icomoon icons (CC BY 4.0)—all compatible with permissive use.
Quickstart
import xarray as xr
import numpy as np
# Create a labeled DataArray with dimensions and coordinates
data = xr.DataArray(
np.random.rand(3, 4),
dims=['x', 'y'],
coords={'x': ['a', 'b', 'c'], 'y': ['w', 'x', 'y', 'z']}
)
# Select by label
result = data.sel(x='b')
# Sum over a named dimension
sum_x = data.sum('x')
Requires Python 3.11 or later.
Verify before relying
- Whether dask integration for parallel computing is included by default or requires a separate optional dependency.
- Performance characteristics for very large datasets relative to raw NumPy.
- Specific netCDF file format versions and I/O backends supported.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, packaging, pandas |
| Maintenance | actively maintained — 36 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 20,745,538/month — #1,027 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xarray-2026.7.0-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
sparseProvides multi-dimensional sparse array data…
permissive · top 5,000 on PyPI
spatial_imagespatial-image provides an N-dimensional spatial…
permissive · top 15,000 on PyPI
xarray-einstatsProvides xarray-friendly wrappers around NumPy…
permissive · top 5,000 on PyPI
cf-xarraycf-xarray adds a `.cf` accessor to xarray…
permissive · top 15,000 on PyPI
linopylinopy builds linear, integer, and quadratic…
permissive · top 15,000 on PyPI
odc-loaderConstructs xarray objects from parsed…
permissive · top 15,000 on PyPI
xarray-dataclassDefines typed xarray DataArray and Dataset…
permissive · top 15,000 on PyPI
pint-xarrayAdds physical units support to xarray datasets…
permissive · top 15,000 on PyPI
ndcubendcube manipulates, inspects, and visualizes…
unclear · top 15,000 on PyPI
floxFlox provides fast GroupBy reduction operations…
permissive · top 15,000 on PyPI