Skip to content
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

Merged
merged 4 commits into from
Feb 4, 2025

Conversation

quangngd
Copy link
Contributor

@quangngd quangngd commented Feb 2, 2025

Please instruct of which whatsnew to add. As of the time of writing there are 2.3.0 and 3.0.0

@@ -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):
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Member

@mroeschke mroeschke left a 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

@mroeschke mroeschke added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Feb 3, 2025
@mroeschke mroeschke added this to the 3.0 milestone Feb 4, 2025
@mroeschke mroeschke merged commit e830603 into pandas-dev:main Feb 4, 2025
38 of 42 checks passed
@mroeschke
Copy link
Member

Thanks @quangngd

ShashwatAgrawal20 pushed a commit to ShashwatAgrawal20/pandas that referenced this pull request Feb 4, 2025
* return early if set_levels is empty

* add test

* add whatsnew

* check empty before make set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: stack with future_stack=True and empty list
2 participants