🍾 Xarray is now 10 years old! 🎉

xarray.DataArray.isin

Contents

xarray.DataArray.isin#

DataArray.isin(test_elements)[source]#

Tests each value in the array for whether it is in test elements.

Parameters:

test_elements (array_like) – The values against which to test each value of element. This argument is flattened if an array or array_like. See numpy notes for behavior with non-array-like parameters.

Returns:

isin (DataArray or Dataset) – Has the same type and shape as this object, but with a bool dtype.

Examples

>>> array = xr.DataArray([1, 2, 3], dims="x")
>>> array.isin([1, 3])
<xarray.DataArray (x: 3)> Size: 3B
array([ True, False,  True])
Dimensions without coordinates: x

See also

numpy.isin