# xarray.Index.stack

#### *classmethod* Index.stack(variables, dim)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/indexes.py#L132-L155)

Create a new index by stacking coordinate variables into a single new
dimension.

Implementation is optional but required in order to support `stack`.
Otherwise it will raise an error when trying to pass the Index subclass
as argument to [`Dataset.stack()`](xarray.Dataset.stack.html.md#xarray.Dataset.stack).

* **Parameters:**
  * **variables** ([dict-like](https://docs.python.org/3/glossary.html#term-mapping)) – Mapping of [`Variable`](xarray.Variable.html.md#xarray.Variable) objects to stack together.
  * **dim** (`Hashable`) – Name of the new, stacked dimension.
* **Returns:**
  `index` – A new Index object.
