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)
| 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 | """ |