Dataset.stack(self, dimensions: Mapping[Hashable, Sequence[Hashable]] = None, **dimensions_kwargs: Sequence[Hashable]) → 'Dataset'

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.

  • dimensions (Mapping of the form new_name=(dim1, dim2, ..)) – Names of new dimensions, and the existing dimensions that they replace. An ellipsis () will be replaced by all unlisted dimensions. Passing a list containing an ellipsis (stacked_dim=[…]) will stack over all dimensions.

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


stacked – Dataset with stacked data.

Return type