xarray.DataArray.set_index

DataArray.set_index(self, indexes: Union[Mapping[Hashable, Any], NoneType] = None, append: bool = False, inplace: Union[bool, NoneType] = None, **indexes_kwargs: Any) → Union[ForwardRef('DataArray'), NoneType]

Set DataArray (multi-)indexes using one or more existing coordinates.

Parameters
indexes{dim: index, …}

Mapping from names matching dimensions and values given by (lists of) the names of existing coordinates or variables to set as new (multi-)index.

appendbool, optional

If True, append the supplied index(es) to the existing index(es). Otherwise replace the existing index(es) (default).

inplacebool, optional

If True, set new index(es) in-place. Otherwise, return a new DataArray object.

**indexes_kwargs: optional

The keyword arguments form of indexes. One of indexes or indexes_kwargs must be provided.

Returns
objDataArray

Another DataArray, with this data but replaced coordinates. Return None if inplace=True.