🍾 Xarray is now 10 years old! 🎉

xarray.Variable.stack

Contents

xarray.Variable.stack#

Variable.stack(dim=None, **dim_kwargs)[source]#

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

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

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

  • **dim_kwargs – The keyword arguments form of dim. One of dim or dim_kwargs must be provided.

Returns:

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

See also

Variable.unstack