Skip to main content

N-D labeled arrays and datasets in Python

Project description

xarray: N-D labeled arrays and datasets

CI Code coverage Docs Benchmarked with asv Formatted with black Checked with mypy Available on pypi PyPI - Downloads Conda - Downloads DOI Examples on binder Twitter

xarray (pronounced "ex-array", formerly known as xray) is an open source project and Python package that makes working with labelled multi-dimensional arrays simple, efficient, and fun!

Xarray introduces labels in the form of dimensions, coordinates and attributes on top of raw NumPy-like arrays, which allows for a more intuitive, more concise, and less error-prone developer experience. The package includes a large and growing library of domain-agnostic functions for advanced analytics and visualization with these data structures.

Xarray was inspired by and borrows heavily from pandas, the popular data analysis package focused on labelled tabular data. It is particularly tailored to working with netCDF files, which were the source of xarray's data model, and integrates tightly with dask for parallel computing.

Why xarray?

Multi-dimensional (a.k.a. N-dimensional, ND) arrays (sometimes called "tensors") are an essential part of computational science. They are encountered in a wide range of fields, including physics, astronomy, geoscience, bioinformatics, engineering, finance, and deep learning. In Python, NumPy provides the fundamental data structure and API for working with raw ND arrays. However, real-world datasets are usually more than just raw numbers; they have labels which encode information about how the array values map to locations in space, time, etc.

Xarray doesn't just keep track of labels on arrays -- it uses them to provide a powerful and concise interface. For example:

  • Apply operations over dimensions by name: x.sum('time').
  • Select values by label instead of integer location: x.loc['2014-01-01'] or x.sel(time='2014-01-01').
  • Mathematical operations (e.g., x - y) vectorize across multiple dimensions (array broadcasting) based on dimension names, not shape.
  • Flexible split-apply-combine operations with groupby: x.groupby('time.dayofyear').mean().
  • Database like alignment based on coordinate labels that smoothly handles missing values: x, y = xr.align(x, y, join='outer').
  • Keep track of arbitrary metadata in the form of a Python dictionary: x.attrs.

Documentation

Learn more about xarray in its official documentation at https://docs.xarray.dev/.

Try out an interactive Jupyter notebook.

Contributing

You can find information about contributing to xarray at our Contributing page.

Get in touch

  • Ask usage questions ("How do I?") on GitHub Discussions.
  • Report bugs, suggest features or view the source code on GitHub.
  • For less well defined questions or ideas, or to announce other projects of interest to xarray users, use the mailing list.

NumFOCUS

Xarray is a fiscally sponsored project of NumFOCUS, a nonprofit dedicated to supporting the open source scientific computing community. If you like Xarray and want to support our mission, please consider making a donation to support our efforts.

History

Xarray is an evolution of an internal tool developed at The Climate Corporation. It was originally written by Climate Corp researchers Stephan Hoyer, Alex Kleeman and Eugene Brevdo and was released as open source in May 2014. The project was renamed from "xray" in January 2016. Xarray became a fiscally sponsored project of NumFOCUS in August 2018.

Contributors

Thanks to our many contributors!

Contributors

License

Copyright 2014-2024, xarray Developers

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Xarray bundles portions of pandas, NumPy and Seaborn, all of which are available under a "3-clause BSD" license:

  • pandas: setup.py, xarray/util/print_versions.py
  • NumPy: xarray/core/npcompat.py
  • Seaborn: _determine_cmap_params in xarray/core/plot/utils.py

Xarray also bundles portions of CPython, which is available under the "Python Software Foundation License" in xarray/core/pycompat.py.

Xarray uses icons from the icomoon package (free version), which is available under the "CC BY 4.0" license.

The full text of these licenses are included in the licenses directory.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray-2025.1.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

xarray-2025.1.1-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file xarray-2025.1.1.tar.gz.

File metadata

  • Download URL: xarray-2025.1.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xarray-2025.1.1.tar.gz
Algorithm Hash digest
SHA256 1a3011d00ca92a94ba31b297c2eccd310b87a7dacf5acc8d0468385d4a834342
MD5 9dfb32d035b2c1b2e6e1f10c1b356303
BLAKE2b-256 c5e7e42216792114b13db0f026ca3485ce163145df9cea8b5b81ff296b113869

See more details on using hashes here.

Provenance

The following attestation bundles were made for xarray-2025.1.1.tar.gz:

Publisher: pypi-release.yaml on pydata/xarray

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xarray-2025.1.1-py3-none-any.whl.

File metadata

  • Download URL: xarray-2025.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xarray-2025.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a69d17c1e4ad09664fd0bc2dbb398e7368eda25bd19456fb919a6eb6490fb72
MD5 d0c8b658ae3d93e08d9e698c250f7364
BLAKE2b-256 1478cd4d5294e0a7294243d332fdd00a020942faa41472e694f2552976a5fe39

See more details on using hashes here.

Provenance

The following attestation bundles were made for xarray-2025.1.1-py3-none-any.whl:

Publisher: pypi-release.yaml on pydata/xarray

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page