4

I get the following error when running pd.core.format.header_style = None:

AttributeError                            Traceback (most recent call last)
<ipython-input-25-fb23b66754fa> in <module>()
     11 # df1.to_excel(writer, sheet_name='Sheet1')
     12 
---> 13 pd.core.format.header_style = None

AttributeError: module 'pandas.core' has no attribute 'format'

Does anybody know where format has moved to?

James Draper
  • 5,110
  • 5
  • 40
  • 59

1 Answers1

11

You're now looking for

pd.formats.format.header_style = None

I believe, as of version 0.18.1. See the issue CLN & REORG core/common.py #12503.


Edit (version >= 0.20)

As mentioned by Jeff, this is not a public property and so is prone to move around. Now it is found in pandas.io.formats.excel, which you'll have to import.

If you wanted to handle accessing it from different versions thus far (again, susceptible to change), an adaptation from this incompatibility issue might look something like

import packaging.version
import pandas
import pandas.io.formats.excel

def get_format_module():
    version = packaging.version.parse(pandas.__version__)
    if version < packaging.version.parse('0.18'):
        return pandas.core.format
    elif version < packaging.version.parse('0.20'):
        return pandas.formats.format
    else:
        return pandas.io.formats.excel.ExcelFormatter
Oskar Austegard
  • 4,599
  • 4
  • 36
  • 50
miradulo
  • 28,857
  • 6
  • 80
  • 93