![](/img/trans.png)
[英]TypeError: 'float' object is not subscriptable in openpyxl function dataframe_to_rows
[英]openpyxl module - can't find openpyxl.utils.dataframe.dataframe_to_rows function
我目前正在使用 Pandas 和 Excel,并且正在使用 openpyxl 模块。
我正在尝试将 DataFrame 编写为 excel,并且 openpyxl 文档指出应该使用“openpyxl.utils.dataframe.dataframe_to_rows()”函数。 ( http://openpyxl.readthedocs.io/en/default/pandas.html )
但是,当我尝试使用它时,出现以下错误:
from openpyxl.utils.dataframe import dataframe_to_rows
for r in dataframe_to_rows(df, index=True, header=True):
ws.append(r)
ImportError: No module named 'openpyxl.utils.dataframe'
我试过了:
import openpyxl.utils
哪个工作没有问题。
当我运行时:
dir(openpyxl.utils)
我没有看到任何提及“数据框”的内容。
我做错了什么,还是 openpyxl 的文档已经过时了?
任何人都知道如何轻松地将数据框传输到我用 openpyxl 打开的 Excel 工作簿中?
查理克拉克的正确答案 - 我有 2.3.2 版,我升级到 2.4.1 版,此时导入工作。
尝试:
import openpyxl.utils.dataframe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.