Closed
Description
It should be relatively straightforward to allow slicing on coordinates that are not backed by an IndexVariable, or in other words coordinates that are on a dimension with a different name, as long as they are 1-dimensional (unsure about the multidimensional case).
E.g. given this array:
a = xarray.DataArray(
[10, 20, 30],
dims=['country'],
coords={
'country': ['US', 'Germany', 'France'],
'currency': ('country', ['USD', 'EUR', 'EUR'])
})
<xarray.DataArray (country: 3)>
array([10, 20, 30])
Coordinates:
* country (country) <U7 'US' 'Germany' 'France'
currency (country) <U3 'USD' 'EUR' 'EUR'
This is currently not possible:
a.sel(currency='EUR')
ValueError: dimensions or multi-index levels ['currency'] do not exist
It should be interpreted as a shorthand for:
a.sel(country=a.currency == 'EUR')
<xarray.DataArray (country: 2)>
array([20, 30])
Coordinates:
* country (country) <U7 'Germany' 'France'
currency (country) <U3 'EUR' 'EUR'