我尝试了两种方法,但我一直收到错误。
我当前的代码:
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})
writer = pd.ExcelWriter('/Users/anonymous/Desktop/Version4.xlsx', engine='xlsxwriter').
df.to_excel(writer, sheet_name='Ex1')
writer.save()
I have the following error:
.... import xlsxwriter ModuleNotFoundError: No module named 'xlsxwriter'
我也试过没有引擎然后它有相同的错误,除了模块是openpyxl。我检查确保在我的终端中安装了两个。
答案 0 :(得分:2)
兄弟,
你尝试过简单的吗?pd.read_excel()
pd.to_excel()
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_excel.html
答案 1 :(得分:1)
打开命令脚本。转到开始,搜索 cmd ,然后安装pip。 我遇到了这个错误,然后通过另一个解决方案解决了这个问题:
pip install xlsxwriter