๐Ÿพ Xarray is now 10 years old! ๐ŸŽ‰

xarray.DataArray.drop_isel

xarray.DataArray.drop_isel#

DataArray.drop_isel(indexers=None, **indexers_kwargs)[source]#

Drop index positions from this DataArray.

Parameters:
  • indexers (mapping of Hashable to Any or None, default: None) โ€“ Index locations to drop

  • **indexers_kwargs ({dim: position, ...}, optional) โ€“ The keyword arguments form of dim and positions

Returns:

dropped (DataArray)

Raises:

IndexError โ€“

Examples

>>> da = xr.DataArray(np.arange(25).reshape(5, 5), dims=("X", "Y"))
>>> da
<xarray.DataArray (X: 5, Y: 5)> Size: 200B
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])
Dimensions without coordinates: X, Y
>>> da.drop_isel(X=[0, 4], Y=2)
<xarray.DataArray (X: 3, Y: 4)> Size: 96B
array([[ 5,  6,  8,  9],
       [10, 11, 13, 14],
       [15, 16, 18, 19]])
Dimensions without coordinates: X, Y
>>> da.drop_isel({"X": 3, "Y": 3})
<xarray.DataArray (X: 4, Y: 4)> Size: 128B
array([[ 0,  1,  2,  4],
       [ 5,  6,  7,  9],
       [10, 11, 12, 14],
       [20, 21, 22, 24]])
Dimensions without coordinates: X, Y