xarray.Dataset.isel

Dataset.isel(drop=False, **indexers)

Returns a new dataset with each array indexed along the specified dimension(s).

This method selects values from each array using its __getitem__ method, except this method does not require knowing the order of each array’s dimensions.

Parameters:

drop : bool, optional

If drop=True, drop coordinates variables indexed by integers instead of making them scalar.

**indexers : {dim: indexer, …}

Keyword arguments with names matching dimensions and values given by integers, slice objects or arrays. indexer can be a integer, slice, array-like or DataArray. If DataArrays are passed as indexers, xarray-style indexing will be carried out. See Indexing and selecting data for the details.

Returns:

obj : Dataset

A new Dataset with the same contents as this dataset, except each array and dimension is indexed by the appropriate indexers. If indexer DataArrays have coordinates that do not conflict with this object, then these coordinates will be attached. In general, each array’s data will be a view of the array’s data in this dataset, unless vectorized indexing was triggered by using an array indexer, in which case the data will be a copy.