-
-
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
[Feature Request] Dataset.loc should accept comparisons with a contained DataArray as key #2689
Comments
Hi Jendrik, thanks for your interest! Could you please give an example of what exactly your proposed syntax would look like, with example inputs/outputs? |
Hey Shoyer, sure I am happy to propose one. xarr = xarr.loc[xarr['tmin'] > 5] If the DataArray is one dimensional this is straight forward to achieve by altering the _LocIndexer in the following way:
This does not work for higher dimensions though as 2-dimensional boolean indexing is not supported. Cheers, Jendrik |
Oh, OK, that makes sense now. Yes, we are definitely interested in supporting multi-dimensional boolean indexing. See #1887 for thoughts on what this could look. |
Okay will have a look at #1887 first, before going forward with this request :) |
I'm going to close this in favor of #1887. Not to reject this approach, but just to keep discussion in one place. |
Hey xarray maintainers,
first of all, I love this repository! Thanks for all your effort.
I have a feature request for the .loc function of the Dataset class.
I think it would be beneficial to allow comparisons with DataArrays as keys for the loc function.
Obviously, this only works for DataArrays which contain the same dimensions or more than the indexer.
But e.g. in the weather dataset used as the example in the docs, it would allow one to filter precipitation and temperature by longitude or latitude, or precipitation by temperature.
I started implementing it, cause I required it for another use case.
I would be happy to integrate it to xarray, if it is of interest.
Cheers,
Jendrik
The text was updated successfully, but these errors were encountered: