pandas 提升:AttributeError:模块'pandas.core'没有属性'format' [英] Pandas raising: AttributeError: module 'pandas.core' has no attribute 'format'

查看:122
本文介绍了 pandas 提升:AttributeError:模块'pandas.core'没有属性'format'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行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'

有人知道format搬到哪里了吗?

Does anybody know where format has moved to?

推荐答案

您正在寻找

pd.formats.format.header_style = None

我相信,从版本0.18.1开始.请参阅问题 CLN& REORG core/common.py#12503 .

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

编辑(版本> = 0.20)

正如Jeff所提到的,这不是公共财产,因此很容易四处走动.现在可以在 ,您必须将其导入.

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

这篇关于 pandas 提升:AttributeError:模块'pandas.core'没有属性'format'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆