issues: 245776862
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
245776862 | MDU6SXNzdWUyNDU3NzY4NjI= | 1491 | Selecting over a MultiIndex coordinate drops coordinate in question | 21200354 | closed | 0 | 2 | 2017-07-26T16:15:55Z | 2019-07-27T00:04:04Z | 2019-07-27T00:04:04Z | NONE | Selecting over a Dataset or DataArray using a coordinate that's part of a MultiIndex drops the coordinate over which the selection was made. ``` Initialising (time, lat, lon) arraystime = pd.date_range(start='2008-01-01 00:00:00', end='2008-01-01 12:00:00', freq='1H') latitude = np.linspace(-30, 30, 13) longitude = np.linspace(0, 60, 13) ``` Creating a simple Dataset with (time, lat, lon) variables along the same track. ``` Create a datasetds = xray.Dataset(data_vars={'time':xray.Variable(['index'], time), 'latitude':xray.Variable(['index'], latitude), 'longitude':xray.Variable(['index'], longitude)}, coords={'index':xray.IndexVariable(['index'], data=np.arange(13))}) ``` If we create a MultiIndex then select over the time coordinate...
In the output the time coordinate has been dropped entirely, whether the selection was as a scalar or over a slice:
Expected behaviour would be to retain the time coordinate within the MultiIndex, possibly with an option to drop scalar coordinates. Seems like this behaviour might be related to other coordinate-dropping behaviour: #1470 and #1483 ? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/1491/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |