N-D labeled arrays and datasets in Python
Clone or download
gerritholl and jhamman add missing , and article in error message (#2557)
Add missing , and article in error message when attribute values have the wrong type.
Latest commit 70e9eb8 Nov 16, 2018
Failed to load latest commit information.
.github tests shoudn't need to pass for a PR (#2471) Oct 7, 2018
asv_bench Avoid use of deprecated get= parameter in tests (#2500) Oct 23, 2018
ci add full test env for py37 ci env (#2545) Nov 6, 2018
doc revert to dev version for 0.11.1 Nov 7, 2018
examples Correct two github URLs. (#2130) May 14, 2018
licenses isin: better docs, support older numpy and use dask.array.isin. (#2038) Apr 6, 2018
properties isort (#2469) Oct 7, 2018
xarray add missing , and article in error message (#2557) Nov 16, 2018
.coveragerc Fixing xray -> xarray Jan 18, 2016
.gitattributes Versioneer (#2163) May 20, 2018
.gitignore Align DataArrays based on coords in Dataset constructor (#1826) May 31, 2018
.landscape.yml add landscape.yml config file and landscape badge to readme Sep 30, 2015
.pep8speaks.yml Ignore W504 with pep8speaks (#2474) Oct 10, 2018
.travis.yml switch travis language to generic (#2432) Sep 26, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jan 10, 2018
HOW_TO_RELEASE Simplify release checklist Jul 18, 2018
LICENSE Initial commit Sep 30, 2013
MANIFEST.in Versioneer (#2163) May 20, 2018
README.rst Update NumFOCUS donate link (#2421) Sep 19, 2018
appveyor.yml add ISSUE_TEMPLATE for github and xr.show_versions() (#1485) Oct 28, 2017
conftest.py dl tutorial files to tmp directory, then move them once successful (#… May 21, 2017
readthedocs.yml Make RTD builds faster (#2310) Jul 27, 2018
setup.cfg Fix versioneer, release v0.10.6 Jun 1, 2018
setup.py DOC: update whatsnew for xarray 0.11 release (#2548) Nov 7, 2018
versioneer.py isort (#2469) Oct 7, 2018


xarray: N-D labeled arrays and datasets

https://travis-ci.org/pydata/xarray.svg?branch=master https://ci.appveyor.com/api/projects/status/github/pydata/xarray?svg=true&passingText=passing&failingText=failing&pendingText=pending https://readthedocs.org/projects/xray/badge/?version=latest http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A

xarray (formerly xray) is an open source project and Python package that aims to bring the labeled data power of pandas to the physical sciences, by providing N-dimensional variants of the core pandas data structures.

Our goal is to provide a pandas-like and pandas-compatible toolkit for analytics on multi-dimensional arrays, rather than the tabular data for which pandas excels. Our approach adopts the Common Data Model for self- describing scientific data in widespread use in the Earth sciences: xarray.Dataset is an in-memory representation of a netCDF file.

Why xarray?

Adding dimensions names and coordinate indexes to numpy's ndarray makes many powerful array operations possible:

  • 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.

pandas provides many of these features, but it does not make use of dimension names, and its core data structures are fixed dimensional arrays.

Why isn't pandas enough?

pandas excels at working with tabular data. That suffices for many statistical analyses, but physical scientists rely on N-dimensional arrays -- which is where xarray comes in.

xarray aims to provide a data analysis toolkit as powerful as pandas but designed for working with homogeneous N-dimensional arrays instead of tabular data. When possible, we copy the pandas API and rely on pandas's highly optimized internals (in particular, for fast indexing).

Why netCDF?

Because xarray implements the same data model as the netCDF file format, xarray datasets have a natural and portable serialization format. But it is also easy to robustly convert an xarray DataArray to and from a numpy ndarray or a pandas DataFrame or Series, providing compatibility with the full PyData ecosystem.

Our target audience is anyone who needs N-dimensional labeled arrays, but we are particularly focused on the data analysis needs of physical scientists -- especially geoscientists who already know and love netCDF.


The official documentation is hosted on ReadTheDocs at http://xarray.pydata.org/


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

Get in touch

  • Ask usage questions ("How do I?") on StackOverflow.
  • 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.



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.


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.


Copyright 2014-2018, 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


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.

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