pint-xarray icon indicating copy to clipboard operation
pint-xarray copied to clipboard

Explicit indexes in xarray

Open TomNicholas opened this issue 4 years ago • 0 comments

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 avatar Apr 07 '20 18:04 TomNicholas