xarray.where¶
-
xarray.
where
(cond, x, y)¶ Return elements from x or y depending on cond.
Performs xarray-like broadcasting across input arguments.
- Parameters
- Returns
In priority order (Dataset, DataArray, Variable or array, whichever)
type appears as an input argument.
Examples
>>> cond = xr.DataArray([True, False], dims=['x']) >>> x = xr.DataArray([1, 2], dims=['y']) >>> xr.where(cond, x, 0) <xarray.DataArray (x: 2, y: 2)> array([[1, 2], [0, 0]]) Dimensions without coordinates: x, y