-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Partial indexing with a list and hierarchical index #13501
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
So if you have a non-hierarchical index, you expect a reindex:
So So in this case it would maybe indeed make sense to raise ? Other option is to keep as is and ignore those values, or to do a reindex with an empty label for the second level (like reindexing with I thought we already had a discussion on this once, but can't directly find the issue. |
so you are using slicers implicitly here and its ambiguous, see docs here You want something like this?
This is 'partial' indexing (e.g. I can use ':' for give me everything for that level)
So giving a list to the entire input is an error, you can give a list to a single level (e.g. with multiple values). I think this part is a bug
|
@jreback You don't need the IndexSlicer to access a single element, doing I suppose the issue was raised (@jseabold correct me if I am wrong) is because somebody wanted to do the above (and so should have used tuple) but used a list, and that the output was then a bit unexpected. The
So the issue is more regarding: what to do when not all labels are included in a list indexer in case of a MultiIndex ? You can also see this issue when using the more explicit IndexSlice:
The 'c' is ignored in this case (for a single index, you would get a reindex operation introducing NaNs). |
Looks like this example raises now which makes sense to me. Could use a test
|
Code Sample, a copy-pastable example if possible
Teaching a pandas course. Attendee just came across this. Note that we index with a list instead of a tuple at the bottom.
Returns
in both cases on pandas 0.18.1
Expected Output
Error?
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: