-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: reset_index on a MultiIndex with duplicate levels raises a ValueError #44410
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
Comments
The Therefore, the potential bug is calling |
We currently have one test covering the behavior, that this should raise a ValueError, when either names from the index are already represented in the DataFrames columns or the index has duplicated names. So we can deprecate this behavior and change with 2.0 or introduce a new keyword, something like allow_duplicates, which would be backwards compatible Edit: Or warning about this in the rolling docs. Imo accidentially ending up with duplicates in the columns is not desireable |
I see, so the the I don't have any string opinions whether to change that behavior (I'm okay with leaving it alone since it's easier), so in relation to the rolling behavior, I would be in favor of just documenting it. |
take |
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 master branch of pandas.
Reproducible Example
Issue Description
In pandas 1.1.5, this code works fine; the
MultiIndex
looks as you'd expect it to, and thereset_index
call works fine. This code breaks in 1.3.4.Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : 945c9ed
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.0-37-generic
Version : #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.4
numpy : 1.21.4
pytz : 2019.3
dateutil : 2.7.3
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.13.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: