BUG: DataFrame.to_excel() now raises if column parameter contains duplicates #39695
Closed
2 of 3 tasks
Labels
Bug
IO Excel
read_excel, to_excel
Regression
Functionality that used to work in a prior pandas version
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
The example works with pandas 1.1.0, but not with pandas 1.2.1 any more. With 1.2.1 it raises:
If the column argument doesn't contain duplicates (e.g.
columns=["A", "B"]
) it works also in 1.2.1In the documentation of .to_excel() I found no information about an intended change in behaviour.
Expected Output
I expected it to work like with pandas 1.1.0, producing an excel file with the following content:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 9d598a5
python : 3.9.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.2.1
numpy : 1.20.0
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 53.0.0
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
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.6
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: