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

Method stack

xarray/core/variable.py:1530–1560  ·  view source on GitHub ↗

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

(self, dim=None, **dim_kwargs)

Source from the content-addressed store, hash-verified

1528
1529 @partial(deprecate_dims, old_name="dimensions")
1530 def stack(self, dim=None, **dim_kwargs):
1531 """
1532 Stack any number of existing dim into a single new dimension.
1533
1534 New dim will be added at the end, and the order of the data
1535 along each new dimension will be in contiguous (C) order.
1536
1537 Parameters
1538 ----------
1539 dim : mapping of hashable to tuple of hashable
1540 Mapping of form new_name=(dim1, dim2, ...) describing the
1541 names of new dim, and the existing dim that
1542 they replace.
1543 **dim_kwargs
1544 The keyword arguments form of ``dim``.
1545 One of dim or dim_kwargs must be provided.
1546
1547 Returns
1548 -------
1549 stacked : Variable
1550 Variable with the same attributes but stacked data.
1551
1552 See Also
1553 --------
1554 Variable.unstack
1555 """
1556 dim = either_dict_or_kwargs(dim, dim_kwargs, "stack")
1557 result = self
1558 for new_dim, dims in dim.items():
1559 result = result._stack_once(dims, new_dim)
1560 return result
1561
1562 def _unstack_once_full(self, dim: Mapping[Any, int], old_dim: Hashable) -> Self:
1563 """

Callers 7

_unravel_argminmaxMethod · 0.95
test_stackMethod · 0.95
test_stackMethod · 0.95
test_stack_errorsMethod · 0.95
test_unstack_errorsMethod · 0.95
concatMethod · 0.45

Calls 3

either_dict_or_kwargsFunction · 0.90
itemsMethod · 0.80
_stack_onceMethod · 0.45

Tested by 5

test_stackMethod · 0.76
test_stackMethod · 0.76
test_stack_errorsMethod · 0.76
test_unstack_errorsMethod · 0.76