Indexes#
See also
See the Xarray gallery on custom indexes for more examples.
Creating indexes#
cftime_range([start, end, periods, freq, ...])
Return a fixed frequency CFTimeIndex.
date_range([start, end, periods, freq, tz, ...])
Return a fixed frequency datetime index.
date_range_like(source, calendar[, use_cftime])
Generate a datetime array with the same frequency, start and end as another one, but in a different calendar.
indexes.RangeIndex.arange([start, stop, ...])
Create a new RangeIndex from given start, stop and step values.
indexes.RangeIndex.linspace(start, stop[, ...])
Create a new RangeIndex from given start / stop values and number of values.
Built-in Indexes#
Default, pandas-backed indexes built-in to Xarray:
indexes.PandasIndex(array, dim[, ...])
Wrap a pandas.Index as an xarray compatible index.
indexes.PandasMultiIndex(array, dim[, ...])
Wrap a pandas.MultiIndex as an xarray compatible index.
More complex indexes built-in to Xarray:
CFTimeIndex(data[, name])
Custom Index for working with CF calendars and dates
indexes.RangeIndex(transform)
Xarray index implementing a simple bounded 1-dimension interval with evenly spaced, monotonic floating-point values.
indexes.NDPointIndex(tree_obj, *, ...)
Xarray index for irregular, n-dimensional data.
indexes.CoordinateTransformIndex(transform)
Helper class for creating Xarray indexes based on coordinate transforms.
Building custom indexes#
These classes are building blocks for more complex Indexes:
indexes.CoordinateTransform(coord_names, ...)
Abstract coordinate transform with dimension & coordinate names.
indexes.CoordinateTransformIndex(transform)
Helper class for creating Xarray indexes based on coordinate transforms.
indexes.NDPointIndex(tree_obj, *, ...)
Xarray index for irregular, n-dimensional data.
indexes.TreeAdapter(points, *, options)
Lightweight adapter abstract class for plugging in 3rd-party structures like scipy.spatial.KDTree or sklearn.neighbors.KDTree into NDPointIndex.
The Index base class for building custom indexes:
Index()
Base class inherited by all xarray-compatible indexes.
Index.from_variables(variables, *, options)
Create a new index object from one or more coordinate variables.
Index.concat(indexes, dim[, positions])
Create a new index by concatenating one or more indexes of the same type.
Index.stack(variables, dim)
Create a new index by stacking coordinate variables into a single new dimension.
Unstack a (multi-)index into multiple (single) indexes.
Index.create_variables([variables])
Maybe create new coordinate variables from this index.
Index.should_add_coord_to_array(name, var, dims)
Define whether or not an index coordinate variable should be added to a new DataArray.
Cast this xarray index to a pandas.Index object or raise a TypeError if this is not supported.
Index.isel(indexers)
Maybe returns a new index from the current index itself indexed by positional indexers.
Index.sel(labels)
Query the index with arbitrary coordinate label indexers.
Index.join(other[, how])
Return a new index from the combination of this index with another index of the same type.
Index.reindex_like(other)
Query the index with another index of the same type.
Index.equals(other, **kwargs)
Compare this index with another index of the same type.
Index.roll(shifts)
Roll this index by an offset along one or more dimensions.
Index.rename(name_dict, dims_dict)
Maybe update the index with new coordinate and dimension names.
Index.copy([deep])
Return a (deep) copy of this index.
The following are useful when building custom Indexes
IndexSelResult(dim_indexers[, indexes, ...])
Index query results.