xarray.Variable.stack

Variable.stack(dimensions=None, **dimensions_kwargs)

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 form new_name=(dim1, dim2, ..)) – 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 with the same attributes but stacked data.

Return type

Variable