-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
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
from pandas import DataFrame
df = DataFrame(
data={
'A': [1, 2, 1]
},
index=['one', 'two', 'one']
)
transformed_df = (
df
.groupby(level=0,
group_keys=False)
.rolling(window=2,
min_periods=1)
.sum()
)
print(transformed_df)
Issue Description
The example creates a DataFrame
with duplicate index levels even though group_keys=False
:
>>> print(transformed_df)
A
one one 1.0
one 2.0
two two 2.0
Expected Behavior
group_keys=False
should produce a DataFrame
with the same index as the original:
A
one 1.0
one 2.0
two 2.0
Installed Versions
pandas : 2.2.3
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0
pip : 24.2
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : 1.1
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
</details>