-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loc API gives KeyError: "not all values found in index" #3546
Comments
I think sel = da[0, 0] < mask
da[0, 0][sel] If you want to use sel_lon = da[0, 0].lon[sel]
da[0, 0].loc[sel_lon] |
Thanks @mathause , your example works :) This behaviour, however, seems to be slightly different from the |
Hi, @roxyboy This is just because that multidimensional boolean indexing is not yet implemented in xarray (#1887). In [2]: da = xr.DataArray([0, 1, 2], dims=['x'])
In [3]: da.loc[da < 1]
Out[3]:
<xarray.DataArray (x: 1)>
array([0])
Dimensions without coordinates: x FYI, in xarray, probably da.isel(x=da < 1) instead of |
It is still kind of unsatisfying that my initial example fails as |
I am having issues with the loc API of xarray. I am trying to select data that satisfy a certain condition. Below should be a reproducible example:
but this gives the following error:
Since the
mask
is identical to the xarray.DataArrayda
in terms of dimensions and coordinates, I don't think this error makes sense... If I change the coordinates in the following manner:it works:
Am I missing something or is this possibly a bug? Thank you in advance for your help.
The text was updated successfully, but these errors were encountered: