-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
.loc Multiindex DateTime slicing failures #16699
Labels
Milestone
Comments
this should work. welcome to have you look into and submit a PR for this. also, can you add xref to other issues that look relevant. (you can do at the very top of the issue). |
jreback
added
Bug
Difficulty Intermediate
Indexing
Related to indexing on series/frames, not to indexes themselves
MultiIndex
labels
Jun 15, 2017
Related problem: import pandas as pd
dt_idx = pd.to_datetime(['2017-05-04','2017-05-05'])
m_idx = pd.MultiIndex.from_product([dt_idx,dt_idx], names=['Idx1','Idx2'])
df = pd.DataFrame(data=[[1,2],[3,4],[5,6],[7,6]], index=m_idx, columns=['C1','C2'])
print(df.loc[[(pd.to_datetime('2017-05-04'),pd.to_datetime('2017-05-04'))]]) # works as expected
print(df.loc[[('2017-05-04','2017-05-04')]]) # NaN returned
print(df.loc[[pd.to_datetime('2017-05-04')]]) # works
print(df.loc[['2017-05-04']]) # KeyError: "['2017-05-04'] not in index" |
This appears to work on master. Could use a test.
|
mroeschke
added
good first issue
Needs Tests
Unit test(s) needed to prevent regressions
and removed
Bug
Difficulty Intermediate
Indexing
Related to indexing on series/frames, not to indexes themselves
MultiIndex
labels
Oct 21, 2019
10 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related to #16637 and #14946
Code Sample, a copy-pastable example if possible
Problem description
Inconsistent behaviour of .loc slicer when combining with mask (or possibly other data types) leads to fail.
I believe this is either tangentially or directly related to other issues with similar headers but this may be a new variant.
Expected Output
Failed line expected to be equivalent to the working line above.
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: