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

Method isel

xarray/core/dataarray.py:1509–1604  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 15

test_vectorized_indexingFunction · 0.95
__getitem__Method · 0.95
_constructMethod · 0.95
test_default_titleMethod · 0.95
arraysFunction · 0.95
test_groupby_bins_mathFunction · 0.95
test_resampleMethod · 0.95

Calls 9

_to_temp_datasetMethod · 0.95
_from_temp_datasetMethod · 0.95
_replaceMethod · 0.95
either_dict_or_kwargsFunction · 0.90
is_fancy_indexerFunction · 0.90
isel_indexesFunction · 0.90
_isel_fancyMethod · 0.80
itemsMethod · 0.80
valuesMethod · 0.45

Tested by 15

test_vectorized_indexingFunction · 0.76
test_default_titleMethod · 0.76
arraysFunction · 0.76
test_groupby_bins_mathFunction · 0.76
test_resampleMethod · 0.76
test_multiple_groupersFunction · 0.76
test_shuffle_simpleFunction · 0.76