- Notifications
You must be signed in to change notification settings - Fork1.1k
N-D labeled arrays and datasets in Python
License
pydata/xarray
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
xarray (pronounced "ex-array", formerly known asxray) is an open source project and Pythonpackage that makes working with labelled multi-dimensional arrayssimple, efficient, and fun!
Xarray introduces labels in the form of dimensions, coordinates andattributes on top of rawNumPy-like arrays,which allows for a more intuitive, more concise, and less error-pronedeveloper experience. The package includes a large and growing libraryof domain-agnostic functions for advanced analytics and visualizationwith these data structures.
Xarray was inspired by and borrows heavily frompandas, the popular data analysis packagefocused on labelled tabular data. It is particularly tailored to workingwithnetCDF files, whichwere the source of xarray's data model, and integrates tightly withdask for parallel computing.
Multi-dimensional (a.k.a. N-dimensional, ND) arrays (sometimes called"tensors") are an essential part of computational science. They areencountered in a wide range of fields, including physics, astronomy,geoscience, bioinformatics, engineering, finance, and deep learning. InPython,NumPy provides the fundamental datastructure and API for working with raw ND arrays. However, real-worlddatasets are usually more than just raw numbers; they have labels whichencode 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 toprovide 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']
orx.sel(time='2014-01-01')
. - Mathematical operations (e.g.,
x - y
) vectorize across multipledimensions (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 smoothlyhandles missing values:
x, y = xr.align(x, y, join='outer')
. - Keep track of arbitrary metadata in the form of a Python dictionary:
x.attrs
.
Learn more about xarray in its official documentation athttps://docs.xarray.dev/.
Try out aninteractive Jupyternotebook.
You can find information about contributing to xarray at ourContributingpage.
- Ask usage questions ("How do I?") onGitHub Discussions.
- Report bugs, suggest features or view the source codeonGitHub.
- For less well defined questions or ideas, or to announce otherprojects of interest to xarray users, use themailinglist.
Xarray is a fiscally sponsored project ofNumFOCUS, a nonprofit dedicated to supportingthe open source scientific computing community. If you like Xarray andwant to support our mission, please consider making adonation to supportour efforts.
Xarray is an evolution of an internal tool developed atThe ClimateCorporation. It was originally written by ClimateCorp researchers Stephan Hoyer, Alex Kleeman and Eugene Brevdo and wasreleased as open source in May 2014. The project was renamed from"xray" in January 2016. Xarray became a fiscally sponsored project ofNumFOCUS in August 2018.
Thanks to our many contributors!
Copyright 2014-2024, xarray Developers
Licensed under the Apache License, Version 2.0 (the "License"); youmay not use this file except in compliance with the License. You mayobtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
Xarray bundles portions of pandas, NumPy and Seaborn, all of which areavailable under a "3-clause BSD" license:
- pandas:
setup.py
,xarray/util/print_versions.py
- NumPy:
xarray/core/npcompat.py
- Seaborn:
_determine_cmap_params
inxarray/core/plot/utils.py
Xarray also bundles portions of CPython, which is available under the"Python Software Foundation License" inxarray/core/pycompat.py
.
Xarray uses icons from the icomoon package (free version), which isavailable under the "CC BY 4.0" license.
The full text of these licenses are included in the licenses directory.
About
N-D labeled arrays and datasets in Python