Returns a new dataset with each array indexed along the specified dimension(s). This method selects values from each array using its `__getitem__` method, except this method does not require knowing the order of each array's dimensions. Parameters --
(
self,
indexers: Mapping[Any, Any] | None = None,
drop: bool = False,
missing_dims: ErrorOptionsWithWarn = "raise",
**indexers_kwargs: Any,
)
| 2746 | return attached_coords, attached_indexes |
| 2747 | |
| 2748 | def isel( |
| 2749 | self, |
| 2750 | indexers: Mapping[Any, Any] | None = None, |
| 2751 | drop: bool = False, |
| 2752 | missing_dims: ErrorOptionsWithWarn = "raise", |
| 2753 | **indexers_kwargs: Any, |
| 2754 | ) -> Self: |
| 2755 | """Returns a new dataset with each array indexed along the specified |
| 2756 | dimension(s). |
| 2757 | |
| 2758 | This method selects values from each array using its `__getitem__` |
| 2759 | method, except this method does not require knowing the order of |
| 2760 | each array's dimensions. |
| 2761 | |
| 2762 | Parameters |
| 2763 | ---------- |
| 2764 | indexers : dict, optional |
| 2765 | A dict with keys matching dimensions and values given |
| 2766 | by integers, slice objects or arrays. |
| 2767 | indexer can be a integer, slice, array-like or DataArray. |
| 2768 | If DataArrays are passed as indexers, xarray-style indexing will be |
| 2769 | carried out. See :ref:`indexing` for the details. |
| 2770 | One of indexers or indexers_kwargs must be provided. |
| 2771 | drop : bool, default: False |
| 2772 | If ``drop=True``, drop coordinates variables indexed by integers |
| 2773 | instead of making them scalar. |
| 2774 | missing_dims : {"raise", "warn", "ignore"}, default: "raise" |
| 2775 | What to do if dimensions that should be selected from are not present in the |
| 2776 | Dataset: |
| 2777 | - "raise": raise an exception |
| 2778 | - "warn": raise a warning, and ignore the missing dimensions |
| 2779 | - "ignore": ignore the missing dimensions |
| 2780 | |
| 2781 | **indexers_kwargs : {dim: indexer, ...}, optional |
| 2782 | The keyword arguments form of ``indexers``. |
| 2783 | One of indexers or indexers_kwargs must be provided. |
| 2784 | |
| 2785 | Returns |
| 2786 | ------- |
| 2787 | obj : Dataset |
| 2788 | A new Dataset with the same contents as this dataset, except each |
| 2789 | array and dimension is indexed by the appropriate indexers. |
| 2790 | If indexer DataArrays have coordinates that do not conflict with |
| 2791 | this object, then these coordinates will be attached. |
| 2792 | In general, each array's data will be a view of the array's data |
| 2793 | in this dataset, unless vectorized indexing was triggered by using |
| 2794 | an array indexer, in which case the data will be a copy. |
| 2795 | |
| 2796 | Examples |
| 2797 | -------- |
| 2798 | |
| 2799 | >>> dataset = xr.Dataset( |
| 2800 | ... { |
| 2801 | ... "math_scores": ( |
| 2802 | ... ["student", "test"], |
| 2803 | ... [[90, 85, 92], [78, 80, 85], [95, 92, 98]], |
| 2804 | ... ), |
| 2805 | ... "english_scores": ( |