1

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

1
  • 1
    Just put them in a list and call df.to_excel at each iteration Commented Jan 14, 2019 at 19:23

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.