-
-
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
BUG: pivot_table with margins and numeric columns #55933
Conversation
# GH#26568. Use names instead of indices in case of numeric names | ||
new_order_indices = [len(cols)] + list(range(len(cols))) | ||
new_order_names = [row_margin.index.names[i] for i in new_order_indices] | ||
row_margin.index = row_margin.index.reorder_levels(new_order_names) |
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.
Are row_margin.index.names
guaranteed to be unique?
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.
In this case, row_margin.index.names
are the names of the columns in the original df. They should be unique. If user try to pivot_table
on a df with duplicated column names, upstream code would scream first.
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.
Thanks for the explanation. Could you resolve the merge conflict otherwise looks good.
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.
resolved
Thanks @quangngd |
* fix and add test * add whatsnew * rm comment
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.