xarray: N-D labeled arrays and datasets in Python¶
xarray (formerly xray) is an open source project and Python package that makes working with labelled multi-dimensional arrays simple, efficient, and fun!
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.
By introducing dimensions, coordinates, and attributes on top of raw NumPy-like arrays, xarray is able to understand these labels and use them to provide a more intuitive, more concise, and less error-prone experience. Xarray also provides a large and growing library of 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. Xarray can read and write data from most common labeled ND-array storage formats and is particularly tailored to working with netCDF files, which were the source of xarray’s data model.
Documentation¶
Getting Started
User Guide
- Data Structures
- Indexing and selecting data
- Interpolating data
- Computation
- GroupBy: split-apply-combine
- Reshaping and reorganizing data
- Combining data
- Time series data
- Working with pandas
- Serialization and IO
- Parallel computing with Dask
- Plotting
Help & reference
- What’s New
- API reference
- xarray Internals
- Development roadmap
- Contributing to xarray
- Xarray related projects
See also¶
- Stephan Hoyer and Joe Hamman’s Journal of Open Research Software paper describing the xarray project.
- The UW eScience Institute’s Geohackweek tutorial on xarray for geospatial data scientists.
- Stephan Hoyer’s SciPy2015 talk introducing xarray to a general audience.
- Stephan Hoyer’s 2015 Unidata Users Workshop talk and tutorial (with answers) introducing xarray to users familiar with netCDF.
- Nicolas Fauchereau’s tutorial on xarray for netCDF users.
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.
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.
License¶
xarray is available under the open source Apache License.