You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
importpandasaspddf=pd.DataFrame()
old_working=df.stack(level=[]) # does nothing as list of levels is emptynew_broken=df.stack(level=[], future_stack=True) # tries to stack despite the empty list
Issue Description
There is an unexpected behavioral change in stack with future_stack=True. The future_stack variant tries to stack even though the list of levels to stack is empty. The error message is ValueError: Cannot remove 1 levels from an index with 1 levels: at least one level must be left.
Expected Behavior
For me, this happens in code where the levels to stack are determined by a function - and the case of "empty list" seems to be forgotten in the new implementation. So could this behavior be restored in the new stack implementation?
Installed Versions
Tested with pandas 2.2.3.
The text was updated successfully, but these errors were encountered:
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
There is an unexpected behavioral change in stack with future_stack=True. The future_stack variant tries to stack even though the list of levels to stack is empty. The error message is
ValueError: Cannot remove 1 levels from an index with 1 levels: at least one level must be left.
Expected Behavior
For me, this happens in code where the levels to stack are determined by a function - and the case of "empty list" seems to be forgotten in the new implementation. So could this behavior be restored in the new stack implementation?
Installed Versions
Tested with pandas 2.2.3.
The text was updated successfully, but these errors were encountered: