skillfed

xarray

N-D labeled arrays and datasets in Python

xarray v2026.7.0 20.7M downloads/30d#1,027 on PyPI4,189
Permissive license Apache-2.0 Active released

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 xarray

uv

uv add xarray

poetry

poetry add xarray

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/Engineering

Tags

labeled multidimensional arraysnetcdf data handlingdimension-aware array operationsscientific data structuresxarray dataset manipulationlabeled tensor operationsgeospatial data processing
scientific-computingdata-structuresnetcdf

More Scientific/Engineering packages