使用时没有Excel编写器“openpyxl”pandas.to\u卓越()

2024-05-16 20:42:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是热情的Canopy python安装。在

我已经添加了xlwt、xlrd和openpyxl包。在

制作一个非常简单的数据帧,并尝试将其写入两种类型的excel格式--财团法人以及fn.xlsx公司在

写信给财团法人使用(xlwt)的软件包。在

但在努力写作fn.xlsx公司(哪个使用openpyxl?还是xlrd?)包失败,投诉:ValueError: No Excel writer 'openpyxl'

data = {'year': [2010, 2011, 2012, 2011, 2012, 2010, 2011, 2012],
        'team': ['Bears', 'Bears', 'Bears', 'Packers', 'Packers', 'Lions', 'Lions', 'Lions'],
        'wins': [11, 8, 10, 15, 11, 6, 10, 4],
        'losses': [5, 8, 6, 1, 5, 10, 6, 12]}
football = pd.DataFrame(data, columns=['year', 'team', 'wins', 'losses'])
print football

#works
football.to_excel('football.xls', index=False)
#fails:  ValueError: No Excel writer 'openpyxl' 
football.to_excel('football.xlsx', index=False)

输出pd.show_版本():

输出pd.show_版本(): pd.show_版本()

^{pr2}$

我刚注意到一个用户警告启动。。。在

/Users/slater/canopy_64/User/lib/python2.7/site-packages/pandas/io/excel.py:626:

UserWarning: Installed openpyxl is not supported at this time.

Use >=1.6.1 and <2.0.0. .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))

不知道为什么热情的canopy会把不兼容版本的包放在同一个部署包中。。。。在


Tags: 版本show公司xlsxexcelfnpdbears