问题
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