We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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) arrays time = 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 dataset ds = 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...
ds.set_index(index=('time', 'latitude', 'longitude'), inplace=True) ds.sel(**dict(time=slice('2008-01-01 03:00:00', '2008-01-01 09:00:00')))
In the output the time coordinate has been dropped entirely, whether the selection was as a scalar or over a slice:
<xarray.Dataset> Dimensions: (index: 7) Coordinates: * index (index) MultiIndex - latitude (index) float64 -15.0 -10.0 -5.0 0.0 5.0 10.0 15.0 - longitude (index) float64 15.0 20.0 25.0 30.0 35.0 40.0 45.0 Data variables: *empty*
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 ?
The text was updated successfully, but these errors were encountered:
This relates to #1408. A preliminary work has been proposed (#1426) but a discussion for the design decision is still ongoing.
Sorry, something went wrong.
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here or remove the stale label; otherwise it will be marked as closed automatically
stale
No branches or pull requests
Selecting over a Dataset or DataArray using a coordinate that's part of a MultiIndex drops the coordinate over which the selection was made.
Creating a simple Dataset with (time, lat, lon) variables along the same track.
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 ?
The text was updated successfully, but these errors were encountered: