Skip to content
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

Support filtering for entity in Dataset.pr.loc #222

Open
mikapfl opened this issue Apr 19, 2024 · 0 comments
Open

Support filtering for entity in Dataset.pr.loc #222

mikapfl opened this issue Apr 19, 2024 · 0 comments

Comments

@mikapfl
Copy link
Member

mikapfl commented Apr 19, 2024

Is your feature request related to a problem? Please describe.

To filter a dataset for the entity and other dimensions, you have to write:

ds[entity].pr.loc[{"other_dim": other_value}]

that's annoying because you have to treat entity different than other dimensions.

Describe the solution you'd like

We enhance the dataset loc accessor such that

ds.pr.loc[{"entity": entity, "other_dim": other_value}]

is valid.

Describe alternatives you've considered

Maybe we shouldn't do this because the return value of ds.pr.loc is not clearly defined anymore. If entity is in the filter, the return value is a DataArray, if entity is not in the filter, it is a Dataset. That's annoying because static type inference doesn't work anymore. So maybe we shouldn't overcomplicate things and live with the fact that filtering for entities is different from filtering for anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant