-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Bug in xs ignored droplevel #37776
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
Conversation
pandas/core/generic.py
Outdated
return self[key] | ||
if drop_level: | ||
return self[key] | ||
return self[[key]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PITA but this causes us to make a copy instead of a view. can we re-use any of the code in the rest of the method to keep this consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make this pretty complex probably, but will have a look tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work, but got a bit more complex. Using iloc now to select the data if droplevel=False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, some comments, ping on green.
@@ -3749,8 +3752,13 @@ class animal locomotion | |||
) | |||
|
|||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make this part of the higher level if/else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pandas/core/generic.py
Outdated
result.index = new_index | ||
else: | ||
result = ( | ||
self.iloc[:, loc] if not is_scalar(loc) else self.iloc[:, [loc]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth making is_scalar another case in the eliif (I think it will read simpler that way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, reads better, thx.
� Conflicts: � doc/source/whatsnew/v1.2.0.rst
thanks @phofl |
@@ -3747,7 +3750,10 @@ class animal locomotion | |||
name=self.index[loc], | |||
dtype=new_values.dtype, | |||
) | |||
|
|||
elif is_scalar(loc): | |||
result = self.iloc[:, [loc]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we implement #36195, this returns a copy and not a view. In followup can you make this self.iloc[:, slice(loc, loc + 1)]
, probably need to test that we're getting a view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff