1 | initial version |
To remove the zeros from an xarray DataArray called da
, you can use the where
method to create a new array with only the non-zero values:
da_nonzero = da.where(da != 0)
This creates a new DataArray da_nonzero
that only contains the non-zero values of da
. If you want to modify the original array da
in place, you can assign the result back to da
:
da = da.where(da != 0)