将多个数据框导出到Excel

时间:2019-01-14 19:22:55

标签: excel python-3.x dataframe export

我如何用几行将几个数据帧(A,B,C等)导出到一个excel文件?

    Excel_file = pd.ExcelWriter('Excel_file.xlsx', engine='xlsxwriter')
        A.to_excel(A,'A')
        B.to_excel(B,'B')
        C.to_excel(C,'C')
       .
       .
       .

谢谢

1 个答案:

答案 0 :(得分:1)

像这样:

with pd.ExcelWriter('Excel_file.xlsx', engine='xlsxwriter') as Excel_file:
    for df, tabname in zip(list_of_dfs, list_of_sheetnames):
        df.to_excel(Excel_file, tabname)