Pandas Df.to_excel For Multiple Dfs?
So I want to save 2 dataframes into 2 different worksheets, but the same file. My code for this part is: df.to_excel(path, sheet name = 'sheet1') df2.to_excel(path, sheet name = 's
Solution 1:
You can use a writer for this:
with pd.ExcelWriter(output_file) as writer:
for i,df in enumerate(list_of_dfs, start=1):
df.to_excel(writer, sheet_name= 'sheet'+str(i))
writer.save()
Post a Comment for "Pandas Df.to_excel For Multiple Dfs?"