1

I have :

list_of_DataFrames = [df_1, df_2, df_n, ...]

I would like to write each of these dataframes into a distinct excel file.

I tried :

list_of_DataFrames.to_excel("pathTo/ExcelFile.xlsx")

2 Answers 2

1

The list doesn't have a to_excel method. The only way you can do is by looping over the list.

for i in range(len(list_of_DataFrames)):
    list_of_DataFrames[i].to_excel("pathTo/ExcelFile-{}.xlsx".format(i))
Sign up to request clarification or add additional context in comments.

Comments

0
for i, df in enumerate([df_1, df_2, df_n, ...]):
    df.to_excel(f"pathTo/ExcelFile_{i}.xlsx")

Comments

Your Answer

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