API reference

This page provides an auto-generated summary of xarray’s API. For more details and examples, refer to the relevant chapters in the main part of the documentation.

See also: What parts of xarray are considered public API?

Top-level functions

Dataset

Creating a dataset

Attributes

Dictionary interface

Datasets implement the mapping interface with keys given by variable names and values given by DataArray objects.

Dataset contents

Comparisons

Indexing

Missing value handling

Computation

Aggregation: all any argmax argmin idxmax idxmin max mean median min prod sum std var

ndarray methods: astype argsort clip conj conjugate imag round real cumsum cumprod rank

Grouped operations: assign assign_coords first last fillna where quantile

Reshaping and reorganizing

Plotting

DataArray

Attributes

ndarray attributes: ndim shape size dtype nbytes chunks

DataArray contents

ndarray methods: astype item

Indexing

Missing value handling

Comparisons

Computation

Aggregation: all any argmax argmin idxmax idxmin max mean median min prod sum std var

ndarray methods: argsort clip conj conjugate imag searchsorted round real T cumsum cumprod rank

Grouped operations: assign_coords first last fillna where quantile

String manipulation

Datetimelike properties

Datetime properties:

Datetime methods:

Timedelta properties:

Timedelta methods:

Reshaping and reorganizing

Plotting

Universal functions

Warning

With recent versions of numpy, dask and xarray, NumPy ufuncs are now supported directly on all xarray and dask objects. This obviates the need for the xarray.ufuncs module, which should not be used for new code unless compatibility with versions of NumPy prior to v1.13 is required. They will be removed once support for NumPy prior to v1.17 is dropped.

These functions are copied from NumPy, but extended to work on NumPy arrays, dask arrays and all xarray objects. You can find them in the xarray.ufuncs module:

angle arccos arccosh arcsin arcsinh arctan arctan2 arctanh ceil conj copysign cos cosh deg2rad degrees exp expm1 fabs fix floor fmax fmin fmod fmod frexp hypot imag iscomplex isfinite isinf isnan isreal ldexp log log10 log1p log2 logaddexp logaddexp2 logical_and logical_not logical_or logical_xor maximum minimum nextafter rad2deg radians real rint sign signbit sin sinh sqrt square tan tanh trunc

IO / Conversion

Dataset methods

DataArray methods

Coordinates objects

GroupBy objects

Rolling objects

Weighted objects

Coarsen objects

Resample objects

Resample objects also implement the GroupBy interface (methods like map(), reduce(), mean(), sum(), etc.).

Accessors

Custom Indexes

Creating custom indexes

Faceting

Tutorial

Testing

Exceptions

Advanced API

These backends provide a low-level interface for lazily loading data from external file-formats or protocols, and can be manually invoked to create arguments for the load_store and dump_to_store Dataset methods:

Deprecated / Pending Deprecation