openpyxl.utils.dataframe not compatible with pandas >= 0.24
Created originally on Bitbucket by jkornblum (Joshua Kornblum)
This snippet in openpyxl.utils.dataframe.py
is not compatible with later versions of Pandas.
if header:
if df.columns.nlevels > 1:
rows = expand_levels(df.columns.levels, df.columns.labels)
else:
rows = [list(df.columns.values)]
If nlevels > 1 then columns is a MultiIndex type and for MultiIndex the property labels
has been renamed to codes
since pandas 0.24. This code will fail if one has multilevel columns then a call to dataframe_to_rows
will fail.
Will need some logic to choose labels
or codes
or to only support pandas > 0.24.