-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
API: select levels of a MultiIndex #10816
Comments
I swear that there was an old issue/PR that addressed this. If I recall it was proposed do have syntax like |
There is the proposal that the index, if it has a name, should also be accessible as a column (eg |
+1 |
Somebody a good idea for a possible API here? Some ideas (selecting a single level here as example, but it should expand to list of names as well) :
|
why would you do this, rather than #8162? |
In my mind, this is something different, as I said above (#10816 (comment)). But of course that is something to discuss in #8162, but in my mind accessing an index like a column, should also return it as a column, and here I want to select specific levels but still keep an index as the final result. |
My question is why would you want to add moar API? what is the usecase?
|
yes, that would be the same, since a MultiIndex with only one level just becomes a plain Index I can't come up with a specific usecase right now, but I remember that I wanted something like this from time to time. The SO question at the top post also gives a usecase. |
Say you have a multi-index:
and you want to select certain levels of the Index (like you select columns of a frame, I want to select levels of an index and get a subset of the index).
At the moment, some possibilities:
Am I missing an easy way to do this?
And if not, I think we should have a better way to do this.
Note: triggerd by this SO question: http://stackoverflow.com/questions/31991388/combinations-of-multiindex-levels-which-occur-in-a-dataframe (but had already encountered this multiple times)
The text was updated successfully, but these errors were encountered: