MCPcopy
hub / github.com/pydata/xarray / isel

Method isel

xarray/core/indexes.py:260–289  ·  view source on GitHub ↗

Maybe returns a new index from the current index itself indexed by positional indexers. This method should be re-implemented in subclasses of Index if the wrapped index structure supports indexing operations. For example, indexing a ``pandas.Index`` is pretty straigh

(
        self, indexers: Mapping[Any, int | slice | np.ndarray | Variable]
    )

Source from the content-addressed store, hash-verified

258 raise TypeError(f"{self!r} cannot be cast to a pandas.Index object")
259
260 def isel(
261 self, indexers: Mapping[Any, int | slice | np.ndarray | Variable]
262 ) -> Index | None:
263 """Maybe returns a new index from the current index itself indexed by
264 positional indexers.
265
266 This method should be re-implemented in subclasses of Index if the
267 wrapped index structure supports indexing operations. For example,
268 indexing a ``pandas.Index`` is pretty straightforward as it behaves very
269 much like an array. By contrast, it may be harder doing so for a
270 structure like a kd-tree that differs much from a simple array.
271
272 If not re-implemented in subclasses of Index, this method returns
273 ``None``, i.e., calling :py:meth:`Dataset.isel` will either drop the
274 index in the resulting dataset or pass it unchanged if its corresponding
275 coordinate(s) are not indexed.
276
277 Parameters
278 ----------
279 indexers : dict
280 A dictionary of positional indexers as passed from
281 :py:meth:`Dataset.isel` and where the entries have been filtered
282 for the current index.
283
284 Returns
285 -------
286 maybe_index : Index
287 A new Index object or ``None``.
288 """
289 return None
290
291 def sel(self, labels: dict[Any, Any]) -> IndexSelResult:
292 """Query the index with arbitrary coordinate label indexers.

Calls

no outgoing calls

Tested by 5

test_basic_indexingFunction · 0.36
test_outer_indexingFunction · 0.36
test_vectorized_indexingFunction · 0.36
test_basic_indexingFunction · 0.36
test_outer_indexingFunction · 0.36