xarray.DataArray.stack

DataArray.stack(**dimensions)

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

New dimensions will be added at the end, and the corresponding coordinate variables will be combined into a MultiIndex.

Parameters:

**dimensions : keyword arguments of the form new_name=(dim1, dim2, ...)

Names of new dimensions, and the existing dimensions that they replace.

Returns:

stacked : DataArray

DataArray with stacked data.