Export two data frames as one excel file with two sheets in pandas on specified location

后端 未结 1 438
南旧
南旧 2021-01-23 17:11

I have two dataframe as shown below.

df1:

   Date           t_factor    plan           plan_score
0  2020-02-01         5       NaN            0
1  2020-02         


        
相关标签:
1条回答
  • 2021-01-23 17:50

    For me working specify excel file like:

    import os
        
    def save_xls(list_dfs, xls_path):
        with pd.ExcelWriter(xls_path) as writer:
            for n, df in enumerate(list_dfs):
                df.to_excel(writer,'sheet%s' % n)
            writer.save()
    
    save_xls([df1, df2], 'file.xlsx')
    
    0 讨论(0)
提交回复
热议问题