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
dawith a dimension namedtimethat 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
Xand 5 dimensions:The equivalent
iselcall would bebecause dimension
"c"now corresponds to axis number 2 of your data.