-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Wrong behaviour/error when indexing MultiIndex with list #12416
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
Why should it raise a KeyError (the first case of
However, I agree that |
@jorisvandenbossche What you say is true only when you omit some levels. For instance
whatever |
To complement the above...
The last two examples have no valid excuse for not resulting in the same behaviour, I think. |
Even better:
|
I am obtaining similar issues with a DateTimeIndex.
|
I think this bug can be closed. The initial example now works correctly:
The example I reported in my second comment ( The example I reported in my third comment is probably still wrong but unrelated, and also discussed in #15452 . The example reported by @EricPrescottGagnon is not really a bug: |
@toobaz would you like to add a test for the initial examples? |
I suspected this is already tested somewhere, but I'm making a note to check |
Based on a quick search in the 0.20 whatsnew file, there does not seem to be listed something about multi-indexes that is exactly this, so quite possibly it was fixed indirectly for another issue |
I'm confused: this seems to test precisely what we want... except it was already in place when I filed this bug. I don't know if the difference in behaviour in my example came from labels being integers, or form the level of the df having more than one label, or even from the |
Yes, the issue here was related to the fact that the integer was (wrongly) regarded as positional instead of as label |
Test would be good! |
and
should both raise
KeyError
(see #12369 (comment) )The text was updated successfully, but these errors were encountered: