MCPcopy Index your code
hub / github.com/pydata/xarray / unstack

Method unstack

xarray/core/variable.py:1670–1706  ·  view source on GitHub ↗

Unstack an existing dimension into multiple new dimensions. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Note that unlike ``DataArray.unstack`` and ``Dataset.unstack``, this met

(self, dim=None, **dim_kwargs)

Source from the content-addressed store, hash-verified

1668
1669 @partial(deprecate_dims, old_name="dimensions")
1670 def unstack(self, dim=None, **dim_kwargs) -> Variable:
1671 """
1672 Unstack an existing dimension into multiple new dimensions.
1673
1674 New dimensions will be added at the end, and the order of the data
1675 along each new dimension will be in contiguous (C) order.
1676
1677 Note that unlike ``DataArray.unstack`` and ``Dataset.unstack``, this
1678 method requires the existing dimension to contain the full product of
1679 the new dimensions.
1680
1681 Parameters
1682 ----------
1683 dim : mapping of hashable to mapping of hashable to int
1684 Mapping of the form old_dim={dim1: size1, ...} describing the
1685 names of existing dimensions, and the new dimensions and sizes
1686 that they map to.
1687 **dim_kwargs
1688 The keyword arguments form of ``dim``.
1689 One of dim or dim_kwargs must be provided.
1690
1691 Returns
1692 -------
1693 unstacked : Variable
1694 Variable with the same attributes but unstacked data.
1695
1696 See Also
1697 --------
1698 Variable.stack
1699 DataArray.unstack
1700 Dataset.unstack
1701 """
1702 dim = either_dict_or_kwargs(dim, dim_kwargs, "unstack")
1703 result = self
1704 for old_dim, dims in dim.items():
1705 result = result._unstack_once_full(dims, old_dim)
1706 return result
1707
1708 def fillna(self, value):
1709 return ops.fillna(self, value)

Callers 5

test_unstackMethod · 0.95
test_unstackMethod · 0.95
test_unstack_errorsMethod · 0.95
test_unstack_2dMethod · 0.95

Calls 3

either_dict_or_kwargsFunction · 0.90
itemsMethod · 0.80
_unstack_once_fullMethod · 0.80

Tested by 5

test_unstackMethod · 0.76
test_unstackMethod · 0.76
test_unstack_errorsMethod · 0.76
test_unstack_2dMethod · 0.76