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: different behavior of stack(future_stack=True) and stack(future_stack=False) #54948

Closed
3 tasks done
radi0sus opened this issue Sep 2, 2023 · 2 comments · Fixed by #54962
Closed
3 tasks done

BUG: different behavior of stack(future_stack=True) and stack(future_stack=False) #54948

radi0sus opened this issue Sep 2, 2023 · 2 comments · Fixed by #54962
Assignees
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@radi0sus
Copy link

radi0sus commented Sep 2, 2023

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

import pandas as pd 
import numpy as np

c_1 = 'A0', 'B0', 0.11
c_2 = 'A1', 'B1', 0.12
c_3 = 'A2', 'B2', 0.14
df=pd.DataFrame(np.random.rand(3,3), columns= [c_1,c_2,c_3], index = ['(i1, i2, i3)','(i4, i5, i6)','(i7, i8, i9)'])
print(df)
#okay:
print(df.stack(future_stack=False))
print(df.unstack())
#error:
print(df.stack(future_stack=True))

Issue Description

Reporting a different behavior of stack() if future_stack=True. There is a
KeyError: "None of [Index(['A0'], dtype='object')] are in the [columns]" in case of future_stack=True.

Expected Behavior

Expected behavior ist the output from the following part of the above example:

.....
#okay:
print(df.stack(future_stack=False))
.....

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.11.5.final.0
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:52 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8103
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8

pandas : 2.1.0
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.1.2
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.2
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@radi0sus radi0sus added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 2, 2023
@radi0sus radi0sus changed the title BUG: BUG: different behavior of stack(future_stack=True) and stack(future_stack=False) Sep 2, 2023
@phofl
Copy link
Member

phofl commented Sep 2, 2023

cc @rhshadrach

@rhshadrach rhshadrach self-assigned this Sep 2, 2023
@rhshadrach
Copy link
Member

Thanks for the report!

@rhshadrach rhshadrach added Regression Functionality that used to work in a prior pandas version Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 2, 2023
@rhshadrach rhshadrach added this to the 2.1.1 milestone Sep 2, 2023
@rhshadrach rhshadrach removed the Regression Functionality that used to work in a prior pandas version label Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants