-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Not possible to find first element in non-monotonic DateTimeIndex if string is used #13572
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
Thanks for the report. The cause seems to be somewhere around here where So the monotonicity is a bit of a red herring, the real problem is that the matching key is in the 0th position. Interested in submitting a fix? Shouldn't be too bad. |
this is already clearly documented here: http://pandas.pydata.org/pandas-docs/version/0.18.1/gotchas.html#label-based-slicing-conventions |
@jreback This seems strange though, right (on the original In [88]: '2015-01-02' in idx
Out[88]: True
In [89]: '2015-01-01' in idx
Out[89]: False The only difference being that the |
@TomAugspurger The code takes quite a different path if the index is monotonic, starting when a KeyError is raised inside DatetimeIndex._partial_date_slice, so I wouldn't say it's a complete red herring. |
Right, red herring was probably the wrong phrase to use since non-monotonicity is necessary for the bug to occur 😄 |
can i work on this issue? |
This was apparently fixed:
Please reopen if it still can be reproduced. |
There is an inconsistency when you look for dates in a DateTimeIndex if you query using strings and the index is non-monotonic. The first element in the index cannot be found in this way, but if you manually convert it to a timestamp object, or if you look for elements other than the first, then the lookup is successful.
Code Sample, a copy-pastable example if possible
Expected Output
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: