我正在尝试将不同的数据框保存到不同的工作表中,如下所示:
import pandas as pd
from pandas import ExcelWriter
import xlsxwriter
// code
bio = BytesIO()
with pd.ExcelWriter(bio, engine='xlsxwriter') as writer:
dfStats.to_excel(writer, sheet_name='Summary')
dfStockdata.to_excel(writer, sheet_name='HistoricalISIN')
# create the workbook
writer.save() // tried both with and without this line
bio.seek(0)
workbook = bio.read()
excelFile = workbook
但是,我收到以下错误:
TypeError: to_excel() got multiple values for argument 'sheet_name'
我该如何解决这个问题?
最佳答案
您可以尝试使用:
writer = pd.ExcelWriter('output//out.xlsx', engine='xlsxwriter')
dfStats.to_excel(writer, sheet_name='Summary')
dfStockdata.to_excel(writer, sheet_name='HistoricalISIN')
writer.save()
关于python - 类型错误 : to_excel() got multiple values for argument 'sheet_name' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42973684/