2017-09-29 70 views
1

我有0.20.3版本的熊猫安装。我正在尝试将header_style设置为false,以便我可以格式化标题行。 xlsxwriter not applying format to header row of dataframe - Python PandasPython熊猫错误:AttributeError:'模块'对象没有'格式'属性

我不断收到错误:AttributeError的: '模块' 对象有没有属性 '格式'

我已经试过

pd.formats.format.header_style = None 

pd.core.format.header_style = None 

任何想法,我在做什么错了?

enter image description here

回答

2

正如你可以在API中看到的,不存在的模块pandas.formats和pandas.core.format:https://pandas.pydata.org/pandas-docs/stable/api.html 这是正常的,你有这样的错误。

如果您用0.20读取新的API更改,则pandas.formats已成为pandas.io.formats。尝试检查API。

+1

谢谢。 pandas.io.formats的作品。 – ProgSky

+0

这是完美的! –

1

做到这一点的另一种方法suggested by @Martin Evans是直接在Pandas之外编写标题。这样可以避免像上面那样使用不同熊猫版本的问题。

另请参见XlsxWriter docs中的此示例。

+0

太好了。感谢您的链接。我会试试看。 – ProgSky

相关问题