Create a new index by stacking coordinate variables into a single new dimension. Implementation is optional but required in order to support ``stack``. Otherwise it will raise an error when trying to pass the Index subclass as argument to :py:meth:`Dataset.stack`.
(cls, variables: Mapping[Any, Variable], dim: Hashable)
| 130 | |
| 131 | @classmethod |
| 132 | def stack(cls, variables: Mapping[Any, Variable], dim: Hashable) -> Self: |
| 133 | """Create a new index by stacking coordinate variables into a single new |
| 134 | dimension. |
| 135 | |
| 136 | Implementation is optional but required in order to support ``stack``. |
| 137 | Otherwise it will raise an error when trying to pass the Index subclass |
| 138 | as argument to :py:meth:`Dataset.stack`. |
| 139 | |
| 140 | Parameters |
| 141 | ---------- |
| 142 | variables : dict-like |
| 143 | Mapping of :py:class:`Variable` objects to stack together. |
| 144 | dim : Hashable |
| 145 | Name of the new, stacked dimension. |
| 146 | |
| 147 | Returns |
| 148 | ------- |
| 149 | index |
| 150 | A new Index object. |
| 151 | """ |
| 152 | raise NotImplementedError( |
| 153 | f"{cls!r} cannot be used for creating an index of stacked coordinates" |
| 154 | ) |
| 155 | |
| 156 | def unstack(self) -> tuple[dict[Hashable, Index], pd.MultiIndex]: |
| 157 | """Unstack a (multi-)index into multiple (single) indexes. |
no outgoing calls