Reputation: 471
How can I export several dataframes (A,B,C, etc) to one excel file with a few lines?
Excel_file = pd.ExcelWriter('Excel_file.xlsx', engine='xlsxwriter')
A.to_excel(A,'A')
B.to_excel(B,'B')
C.to_excel(C,'C')
.
.
.
thank you
Upvotes: 1
Views: 36
Reputation: 370
Like so:
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)
Upvotes: 1