API reference

Dataset

Creating a dataset

Dataset([variables, attributes]) A netcdf-like data object consisting of variables and attributes which together form a self describing dataset.
open_dataset(nc[, decode_cf, ...]) Load a dataset from a file or file-like object.

Attributes and underlying data

Dataset.coordinates Dictionary of Coordinate objects used for label based indexing.
Dataset.noncoordinates Dictionary of DataArrays whose names do not match dimensions.
Dataset.dimensions Mapping from dimension names to lengths.
Dataset.attrs Dictionary of global attributes on this dataset

Dataset contents

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

Dataset.__getitem__(key) Access the given variable name in this dataset as a DataArray.
Dataset.__setitem__(key, value) Add an array to this dataset.
Dataset.__delitem__(key) Remove a variable from this dataset.
Dataset.update(other[, inplace]) Update this dataset’s variables and attributes with those from another dataset.
Dataset.merge(other[, inplace, ...]) Merge the variables of two datasets into a single new dataset.
Dataset.concat(datasets[, dimension, ...]) Concatenate datasets along a new or existing dimension.
Dataset.copy([deep]) Returns a copy of this dataset.
Dataset.iteritems()
Dataset.itervalues()
Dataset.virtual_variables A frozenset of variable names that don’t exist in this dataset but for which could be created on demand.

Comparisons

Dataset.equals(other) Two Datasets are equal if they have the same variables and all variables are equal.
Dataset.identical(other) Two Datasets are identical if they have the same variables and all variables are identical (with the same attributes), and they also have the same global attributes.

Selecting

Dataset.indexed(**indexers) Return a new dataset with each array indexed along the specified dimension(s).
Dataset.labeled(**indexers) Return a new dataset with each variable indexed by coordinate labels along the specified dimension(s).
Dataset.reindex([copy]) Conform this object onto a new set of coordinates or pandas.Index objects, filling in missing values with NaN.
Dataset.reindex_like(other[, copy]) Conform this object onto the coordinates of another object, filling in missing values with NaN.
Dataset.rename(name_dict) Returns a new object with renamed variables and dimensions.
Dataset.select(*names) Returns a new dataset that contains only the named variables and their coordinates.
Dataset.unselect(*names) Returns a new dataset without the named variables.
Dataset.squeeze([dimension]) Return a new dataset with squeezed data.
Dataset.groupby(group[, squeeze]) Group this dataset by unique values of the indicated group.

IO / Conversion

Dataset.to_netcdf(filepath, **kwdargs) Dump dataset contents to a location on disk using the netCDF4 package.
Dataset.dumps(**kwargs) Serialize dataset contents to a string.
Dataset.dump_to_store(store) Store dataset contents to a backends.*DataStore object.
Dataset.to_dataframe() Convert this dataset into a pandas.DataFrame.
Dataset.from_dataframe(dataframe) Convert a pandas.DataFrame into an xray.Dataset

Dataset internals

These attributes and classes provide a low-level interface for working with Dataset variables. In general you should use the Dataset dictionary- like interface instead and working with DataArray objects:

Dataset.variables Dictionary of Variable objects contained in this dataset.
Variable(dims, data[, attributes, encoding]) A netcdf-like variable consisting of dimensions, data and attributes which describe a single Array.
Coordinate(*args, **kwargs) Subclass of Variable which caches its data as a pandas.Index instead of a numpy.ndarray.

Backends (experimental)

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 from_store and dump_to_store Dataset methods.

backends.NetCDF4DataStore(filename[, mode, ...]) Store for reading and writing data via the Python-NetCDF4 library.
backends.PydapDataStore(url) Store for accessing OpenDAP datasets with pydap.
backends.ScipyDataStore(filename_or_obj[, ...]) Store for reading and writing data via scipy.io.netcdf.

DataArray

DataArray N-dimensional array with labeled coordinates and dimensions.

Attributes and underlying data

DataArray.values The variables’s data as a numpy.ndarray
DataArray.as_index The variable’s data as a pandas.Index.
DataArray.coordinates Dictionary of Coordinate objects used for label based indexing.
DataArray.name The name of the variable in dataset to which array operations are applied.
DataArray.dataset The dataset with which this DataArray is associated.
DataArray.attrs Dictionary storing arbitrary metadata with this array.
DataArray.encoding Dictionary of format-specific settings for how this array should be serialized.
DataArray.variable

Selecting

DataArray.__getitem__(key)
DataArray.__setitem__(key, value)
DataArray.loc Attribute for location based indexing like pandas..
DataArray.indexed(**indexers) Return a new DataArray whose dataset is given by indexing along the specified dimension(s).
DataArray.labeled(**indexers) Return a new DataArray whose dataset is given by selecting coordinate labels along the specified dimension(s).
DataArray.reindex([copy]) Conform this object onto a new set of coordinates or pandas.Index objects, filling in missing values with NaN.
DataArray.reindex_like(other[, copy]) Conform this object onto the coordinates of another object, filling in missing values with NaN.
DataArray.rename(new_name_or_name_dict) Returns a new DataArray with renamed variables.
DataArray.select(*names) Returns a new DataArray with only the named variables, as well as this DataArray’s array variable (and all associated coordinates).
DataArray.unselect(*names) Returns a new DataArray without the named variables.
DataArray.squeeze([dimension]) Return a new DataArray object with squeezed data.

Group operations

DataArray.groupby(group[, squeeze]) Group this dataset by unique values of the indicated group.
DataArray.concat(arrays[, dimension, ...]) Stack arrays along a new or existing dimension to form a new DataArray.

Computations

DataArray.transpose(*dimensions) Return a new DataArray object with transposed dimensions.
DataArray.T
DataArray.reduce(func[, dimension, axis]) Reduce this array by applying func along some dimension(s).
DataArray.get_axis_num(dimension) Return axis number(s) corresponding to dimension(s) in this array.
DataArray.all([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.all along some dimension(s).
DataArray.any([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.any along some dimension(s).
DataArray.argmax([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.argmax along some dimension(s).
DataArray.argmin([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.argmin along some dimension(s).
DataArray.max([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.max along some dimension(s).
DataArray.min([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.min along some dimension(s).
DataArray.mean([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.mean along some dimension(s).
DataArray.std([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.std along some dimension(s).
DataArray.sum([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.sum along some dimension(s).
DataArray.var([dimension, axis]) Reduce this DataArray’s data’ by applying numpy.var along some dimension(s).

Comparisons

DataArray.equals(other) True if two DataArrays have the same dimensions, coordinates and values; otherwise False.
DataArray.identical(other) Like equals, but also checks DataArray names and attributes, and attributes on their coordinates.

IO / Conversion

DataArray.to_dataframe() Convert this array into a pandas.DataFrame.
DataArray.to_series() Convert this array into a pandas.Series.
DataArray.from_series(series) Convert a pandas.Series into an xray.DatasetArray
DataArray.copy([deep]) Returns a copy of this array.

Top-level functions

align(*objects[, join, copy]) Given any number of Dataset and/or DataArray objects, returns new objects with aligned coordinates.