🍾 Xarray is now 10 years old! 🎉

xarray.IndexVariable.stack

xarray.IndexVariable.stack#

IndexVariable.stack(dimensions=None, **dimensions_kwargs)[source]#

Stack any number of existing dimensions into a single new dimension.

New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order.

Parameters:
  • dimensions (mapping of hashable to tuple of hashable) – Mapping of form new_name=(dim1, dim2, …) describing the names of new dimensions, and the existing dimensions that they replace.

  • **dimensions_kwargs – The keyword arguments form of dimensions. One of dimensions or dimensions_kwargs must be provided.

Returns:

stacked (Variable) – Variable with the same attributes but stacked data.

See also

Variable.unstack