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

Explicit indexes in xarray #1

Open
TomNicholas opened this issue Apr 7, 2020 · 0 comments · May be fixed by #4
Open

Explicit indexes in xarray #1

TomNicholas opened this issue Apr 7, 2020 · 0 comments · May be fixed by #4
Labels
indexing Related to indexing xarray objects with unit-aware indexers upstream changes

Comments

@TomNicholas
Copy link
Member

Part of xarray's roadmap is to elevate indexes to be an explicit part of their data model. The task is discussed here and there's an overview of the project here. This would allow users to index their arrays with custom index classes, rather than being forced to use pandas.Index.

This is relevant to pint-xarray integration because it would mean we could do unit-aware label-based indexing, i.e.

da.sel(x=10 * Unit('m'))

At the moment that won't work because the indexers get coerced to pandas.Index internally within xarray, which isn't unit-aware.

To get this working we probably need to create our own custom index class, an IndexQuantity. While the default implementation would either wrap or subclass pandas.index, we should also consider how to write it in such a way that alternative indexers could be wrapped, such as periodic indexers or cKDtree indexers.

@TomNicholas TomNicholas linked a pull request Apr 7, 2020 that will close this issue
@TomNicholas TomNicholas added the indexing Related to indexing xarray objects with unit-aware indexers label Apr 7, 2020
@keewis keewis mentioned this issue Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
indexing Related to indexing xarray objects with unit-aware indexers upstream changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant