openpyxl module - can't find openpyxl.utils.dataframe.dataframe_to_rows function

≯℡__Kan透↙ 提交于 2019-12-25 09:24:49

问题


I am currently working with Pandas and Excel and am using the openpyxl module.

I am attempting to write a DataFrame to excel, and the openpyxl documentation states that one should use the "openpyxl.utils.dataframe.dataframe_to_rows()" function. (http://openpyxl.readthedocs.io/en/default/pandas.html)

However when I try to use it I get the following error:

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'

I have tried:

import openpyxl.utils

Which works with no issues.

Also when I run:

dir(openpyxl.utils)

I don't see any mention of "dataframe".

Am I doing something wrong, or is the documentation for openpyxl out of date?

Anyone have any ideas about how i can easily transfer a dataframe into an excel workbook that i have opened with openpyxl?


回答1:


Correct answer from Charlie Clark - I had version 2.3.2 and I upgraded to version 2.4.1 at which point the import worked.



来源:https://stackoverflow.com/questions/40974626/openpyxl-module-cant-find-openpyxl-utils-dataframe-dataframe-to-rows-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!