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
The data in the "period" column gets mangled up, the value associated with the first record shows up twice and the value of the second record disappears.
The problem appears with both future_stack=True and future_stack=False.
The problem does not appear when stacking "period" series, only when stacking dataframe (so following unstack(), the columns are a mutliindex).
Expected Behavior
It is expected that df.unstack().stack() would return the original records unchanged.
Changing period dtype to 'str' behaves as expected:
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
The data in the "period" column gets mangled up, the value associated with the first record shows up twice and the value of the second record disappears.
The problem appears with both
future_stack=True
andfuture_stack=False
.The problem does not appear when stacking "period" series, only when stacking dataframe (so following unstack(), the columns are a mutliindex).
Expected Behavior
It is expected that
df.unstack().stack()
would return the original records unchanged.Changing period dtype to 'str' behaves as expected:
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.11.11
python-bits : 64
OS : Linux
OS-release : 5.10.226-214.880.amzn2.x86_64
Version : #1 SMP Tue Oct 8 16:18:15 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 1.26.4
pytz : 2025.1
dateutil : 2.9.0.post0
pip : 25.0.1
Cython : None
sphinx : None
IPython : 9.0.2
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.3.0
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : 3.10.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.1
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : 2025.3.0
scipy : 1.15.2
sqlalchemy : 2.0.39
tables : None
tabulate : 0.9.0
xarray : 2025.1.2
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: