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

Method stack

xarray/core/indexes.py:132–154  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

setupMethod · 0.45
setupMethod · 0.45
_prepare_plot1d_dataFunction · 0.45
fail_on_dask_array_inputFunction · 0.45
stackFunction · 0.45
_ensure_1dFunction · 0.45
get_pointsFunction · 0.45
funcFunction · 0.45

Calls

no outgoing calls