Equivalent of np.take for xarray DataArray #7308
-
With numpy one can take the slice of the kth dimension with
Is there an xarray equivalent of the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, it's just From the numpy docs:
In xarray we use dimension names in place of axis numbers, so if if you have a DataArray da.isel(time=2) Or in your example, let's say we have created a dataarray with data da_X = xr.DataArray(data=X, dims=["a", "b", "c", "d", "e"]) The equivalent index=1
da_X.isel(c=index) because dimension |
Beta Was this translation helpful? Give feedback.
Yes, it's just
.isel()
.From the numpy docs:
In xarray we use dimension names in place of axis numbers, so if if you have a DataArray
da
with a dimension namedtime
that corresponds to your axis=2, you could achieve the same thing withOr in your example, let's say we have created a dataarray with data
X
and 5 dimensions:The equivalent
isel
call would bebecause dimension
"c"
now corresponds to axis number 2 of your data.