-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG/API: should MultiIndex with leading integer level fallback to positional? #33355
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
Unless im misunderstanding those two issues, this is different. this is about the behavior of |
They're two different issues.
That's my intuition as well. I would call this a bug. IIRC we had a similar issue with incorrect fallback indexing and decided to deprecate the behavior (rather than just changing it). Does that sound correct? |
Yeah, as I said, it was only from reading the title where I saw "MultiIndex", "level", and "positional" ;-) So So the question then is, do we see MultiIndex as a numerical index or not .. ? |
Interpreting a single label as indexing the first level sounds logical, but is also not fully explicit. So I was wondering what it would give if you do this explicitly (index the first level with 0, index the second level with selecting all). But this actually is failing:
(or am I using IndexSlice wrongly?) |
I'm not sure I've ever seen IndexSlice used with The relevant logic for how we handle integers in
But
|
With loc it indeed works:
But I would say that in this case getitem and loc should work similarly. |
Some more related cases to consider With the example series from above, but now a list indexer:
This is also doing positional indexing. So is this also a bug? With a FloatIndex as first level, it seems even more broken:
(while a single-level FloatIndex is always label-based with integers) |
@jorisvandenbossche heads up: i edited your last comment to define To make sure we're on the same page: my read of that is that The list-like case goes through a separate path, ill have to track it down. |
tentative look at the list-of-ints case: in
we should also have something equivalent to
I think the is_integer and is_floating checks there should just reduce to |
Uh oh!
There was an error while loading. Please reload this page.
My intuition is that
ser[3]
should behave like indexing on just the first level of the MultIIndex:Should we avoid the fallback-to-positional behavior in this case?
The text was updated successfully, but these errors were encountered: