Return a new DataArray whose data is given by selecting indexes along the specified dimension(s). Parameters ---------- indexers : dict, optional A dict with keys matching dimensions and values given by integers, slice objects or arrays.
(
self,
indexers: Mapping[Any, Any] | None = None,
drop: bool = False,
missing_dims: ErrorOptionsWithWarn = "raise",
**indexers_kwargs: Any,
)
| 1507 | return self._from_temp_dataset(ds) |
| 1508 | |
| 1509 | def isel( |
| 1510 | self, |
| 1511 | indexers: Mapping[Any, Any] | None = None, |
| 1512 | drop: bool = False, |
| 1513 | missing_dims: ErrorOptionsWithWarn = "raise", |
| 1514 | **indexers_kwargs: Any, |
| 1515 | ) -> Self: |
| 1516 | """Return a new DataArray whose data is given by selecting indexes |
| 1517 | along the specified dimension(s). |
| 1518 | |
| 1519 | Parameters |
| 1520 | ---------- |
| 1521 | indexers : dict, optional |
| 1522 | A dict with keys matching dimensions and values given |
| 1523 | by integers, slice objects or arrays. |
| 1524 | indexer can be an integer, slice, array-like or DataArray. |
| 1525 | If DataArrays are passed as indexers, xarray-style indexing will be |
| 1526 | carried out. See :ref:`indexing` for the details. |
| 1527 | One of indexers or indexers_kwargs must be provided. |
| 1528 | drop : bool, default: False |
| 1529 | If ``drop=True``, drop coordinates variables indexed by integers |
| 1530 | instead of making them scalar. |
| 1531 | missing_dims : {"raise", "warn", "ignore"}, default: "raise" |
| 1532 | What to do if dimensions that should be selected from are not present in the |
| 1533 | DataArray: |
| 1534 | - "raise": raise an exception |
| 1535 | - "warn": raise a warning, and ignore the missing dimensions |
| 1536 | - "ignore": ignore the missing dimensions |
| 1537 | **indexers_kwargs : {dim: indexer, ...}, optional |
| 1538 | The keyword arguments form of ``indexers``. |
| 1539 | |
| 1540 | Returns |
| 1541 | ------- |
| 1542 | indexed : xarray.DataArray |
| 1543 | |
| 1544 | See Also |
| 1545 | -------- |
| 1546 | :func:`Dataset.isel <Dataset.isel>` |
| 1547 | :func:`DataArray.sel <DataArray.sel>` |
| 1548 | |
| 1549 | :doc:`xarray-tutorial:intermediate/indexing/indexing` |
| 1550 | Tutorial material on indexing with Xarray objects |
| 1551 | |
| 1552 | :doc:`xarray-tutorial:fundamentals/02.1_indexing_Basic` |
| 1553 | Tutorial material on basics of indexing |
| 1554 | |
| 1555 | Examples |
| 1556 | -------- |
| 1557 | >>> da = xr.DataArray(np.arange(25).reshape(5, 5), dims=("x", "y")) |
| 1558 | >>> da |
| 1559 | <xarray.DataArray (x: 5, y: 5)> Size: 200B |
| 1560 | array([[ 0, 1, 2, 3, 4], |
| 1561 | [ 5, 6, 7, 8, 9], |
| 1562 | [10, 11, 12, 13, 14], |
| 1563 | [15, 16, 17, 18, 19], |
| 1564 | [20, 21, 22, 23, 24]]) |
| 1565 | Dimensions without coordinates: x, y |
| 1566 |