Returns a new data tree with each array indexed by tick labels along the specified dimension(s). In contrast to `DataTree.isel`, indexers for this method should use labels instead of integers. Under the hood, this method is powered by using pandas's powerful Index
(
self,
indexers: Mapping[Any, Any] | None = None,
method: str | None = None,
tolerance: int | float | Iterable[int | float] | None = None,
drop: bool = False,
**indexers_kwargs: Any,
)
| 2349 | ) |
| 2350 | |
| 2351 | def sel( |
| 2352 | self, |
| 2353 | indexers: Mapping[Any, Any] | None = None, |
| 2354 | method: str | None = None, |
| 2355 | tolerance: int | float | Iterable[int | float] | None = None, |
| 2356 | drop: bool = False, |
| 2357 | **indexers_kwargs: Any, |
| 2358 | ) -> Self: |
| 2359 | """Returns a new data tree with each array indexed by tick labels |
| 2360 | along the specified dimension(s). |
| 2361 | |
| 2362 | In contrast to `DataTree.isel`, indexers for this method should use |
| 2363 | labels instead of integers. |
| 2364 | |
| 2365 | Under the hood, this method is powered by using pandas's powerful Index |
| 2366 | objects. This makes label based indexing essentially just as fast as |
| 2367 | using integer indexing. |
| 2368 | |
| 2369 | It also means this method uses pandas's (well documented) logic for |
| 2370 | indexing. This means you can use string shortcuts for datetime indexes |
| 2371 | (e.g., '2000-01' to select all values in January 2000). It also means |
| 2372 | that slices are treated as inclusive of both the start and stop values, |
| 2373 | unlike normal Python indexing. |
| 2374 | |
| 2375 | Parameters |
| 2376 | ---------- |
| 2377 | indexers : dict, optional |
| 2378 | A dict with keys matching dimensions and values given |
| 2379 | by scalars, slices or arrays of tick labels. For dimensions with |
| 2380 | multi-index, the indexer may also be a dict-like object with keys |
| 2381 | matching index level names. |
| 2382 | If DataArrays are passed as indexers, xarray-style indexing will be |
| 2383 | carried out. See :ref:`indexing` for the details. |
| 2384 | One of indexers or indexers_kwargs must be provided. |
| 2385 | method : {None, "nearest", "pad", "ffill", "backfill", "bfill"}, optional |
| 2386 | Method to use for inexact matches: |
| 2387 | |
| 2388 | * None (default): only exact matches |
| 2389 | * pad / ffill: propagate last valid index value forward |
| 2390 | * backfill / bfill: propagate next valid index value backward |
| 2391 | * nearest: use nearest valid index value |
| 2392 | tolerance : optional |
| 2393 | Maximum distance between original and new labels for inexact |
| 2394 | matches. The values of the index at the matching locations must |
| 2395 | satisfy the equation ``abs(index[indexer] - target) <= tolerance``. |
| 2396 | drop : bool, optional |
| 2397 | If ``drop=True``, drop coordinates variables in `indexers` instead |
| 2398 | of making them scalar. |
| 2399 | **indexers_kwargs : {dim: indexer, ...}, optional |
| 2400 | The keyword arguments form of ``indexers``. |
| 2401 | One of indexers or indexers_kwargs must be provided. |
| 2402 | |
| 2403 | Returns |
| 2404 | ------- |
| 2405 | obj : DataTree |
| 2406 | A new DataTree with the same contents as this data tree, except each |
| 2407 | variable and dimension is indexed by the appropriate indexers. |
| 2408 | If indexer DataArrays have coordinates that do not conflict with |
no test coverage detected