xarray.DataArray.sel¶
-
DataArray.
sel
(indexers: Optional[Mapping[Hashable, Any]] = None, method: Optional[str] = None, tolerance=None, drop: bool = False, **indexers_kwargs) → xarray.core.dataarray.DataArray¶ Return a new DataArray whose data is given by selecting index labels along the specified dimension(s).
Warning
Do not try to assign values when using any of the indexing methods
isel
orsel
:da = xr.DataArray([0, 1, 2, 3], dims=['x']) # DO NOT do this da.isel(x=[0, 1, 2])[1] = -1
Assigning values with the chained indexing using
.sel
or.isel
fails silently.See also