-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Error when exporting an empty DataFrame with MultiIndex to xlsx file #46873
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
Appears to work on main, could use a test if we don't have one already.
|
I was able to reproduce the error with pd.version == 1.4.2 and pd.version == 1.4.3 in my linux machine too. Did some digging and found out that the error was noticed 2 months prior and has been fixed in main:- #47111. For ref the change is in the line 630 of the following:-
self.df.index[0] has been called on an empty dataframe and is trying to access item in index 0 which is not there. which has been replaced by:-
@mroeschke can you confirm if I am right on this and if I can work on this issue. |
Thanks for finding that #47111 fixed this issue and added an equivalent test as reported in this issue. Therefore closing as fixed and tested, but happy to have you help on other issues! |
@mroeschke Happy to help. Will be on the lookout for some beginner friendly issues like this. |
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
Expected Behavior
Write a sheet with only column header
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19042
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Chinese (Simplified)_China.936
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 57.4.0
Cython : 0.29.28
pytest : 7.1.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : None
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.2.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.0.1
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: