issues: 309691307
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
309691307 | MDU6SXNzdWUzMDk2OTEzMDc= | 2028 | slice using non-index coordinates | 6213168 | closed | 0 | 21 | 2018-03-29T09:53:33Z | 2023-02-08T19:47:22Z | 2022-10-03T10:38:57Z | MEMBER | 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' ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2028/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |