-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
More Robust Implementation of slice
#1465
New issue
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
Comments
While it seems a good idea at first (I've fallen into this as well), I'm not sure this would be a good idea. Look at pandas for example: In [1]: import pandas as pd
In [2]: ts = pd.Series([1, 2, 3, 4,])
In [3]: ts[1:3]
Out[3]:
1 2
2 3
dtype: int64
In [4]: ts[3:1]
Out[4]: Series([], dtype: int64) I don't think one would like the last statement to return something else than an empty series. |
Definitely a fair point, but would it be possible to add an argument to either |
I agree that this is somewhat surprising, but as @fmaussion points out this slicing behavior is consistent with pandas (and Python more generally, nothing that
|
Definitely want to leave it up to you guys but agree that putting it in slice probably doesn't make sense. Adding something to |
Closing in favour of #1613 which has more discussion. |
Currently, only one of the two operations:
ds.sel(lon = slice(X0, X1))
andds.sel(lon = slice(X1, X0))
works; the other will give a data array (or dataset) with zero values. This can be a difficulty when working with different data sets which have different indexing methods.It would be great to have
slice
implemented, at least in the context ofsel
, to check whether the index ofds
is increasing or decreasing, and then take the min and max ofX0
andX1
accordingly.The text was updated successfully, but these errors were encountered: