2
votes

I have 0.20.3 version of pandas install. I am trying to set header_style to false so that i can format the header row. xlsxwriter not applying format to header row of dataframe - Python Pandas

I keep getting error : AttributeError: 'module' object has no attribute 'formats'

I have tried

pd.formats.format.header_style = None 

and

pd.core.format.header_style = None

Any idea what am I doing wrong ?

enter image description here

2

2 Answers

3
votes

As you can see in the API, the module pandas.formats and pandas.core.format do not exist : https://pandas.pydata.org/pandas-docs/stable/api.html It is normal that you have this error.

If you read new API changes with 0.20, pandas.formats has become pandas.io.formats. Try to check the API.

1
votes

Another way to do this, suggested by @Martin Evans, is to write the headers directly, outside of Pandas. This avoids issues like above with different Pandas versions.

See also this example in the XlsxWriter docs.