-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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: stack with empty level list #60826
BUG: stack with empty level list #60826
Conversation
pandas/core/reshape/reshape.py
Outdated
@@ -930,6 +930,8 @@ def stack_v3(frame: DataFrame, level: list[int]) -> Series | DataFrame: | |||
if frame.columns.nunique() != len(frame.columns): | |||
raise ValueError("Columns with duplicate values are not supported in stack") | |||
set_levels = set(level) | |||
if not len(set_levels): |
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.
Nit: Could you just check if not level:
before the set
call?
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.
updated
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.
v3.0.0.rst
would be the appropriate location for the whatsnew note
Thanks @quangngd |
* return early if set_levels is empty * add test * add whatsnew * check empty before make set
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Please instruct of which
whatsnew
to add. As of the time of writing there are 2.3.0 and 3.0.0