# xarray.Dataset.set_xindex

#### Dataset.set_xindex(coord_names, index_cls=None, \*\*options)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L5093-L5207)

Set a new, Xarray-compatible index from one or more existing
coordinate(s). Existing index(es) on the coord(s) will be replaced.

* **Parameters:**
  * **coord_names** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – Name(s) of the coordinate(s) used to build the index.
    If several names are given, their order matters.
  * **index_cls** (`subclass` of `Index`, *optional*) – The type of index to create. By default, try setting
    a `PandasIndex` if `len(coord_names) == 1`,
    otherwise a `PandasMultiIndex`.
  * **\*\*options** – Options passed to the index constructor.
* **Returns:**
  **obj** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – Another dataset, with this dataset’s data and with a new index.
