簡體   English   中英

使用 Python 將列表中的數據幀寫入多個 excel 文件

[英]Write dataframes from a list into multiple excel file using Python

我有:

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

我想將這些數據幀中的每一個寫入一個不同的 excel 文件。

我試過了:

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

該列表沒有to_excel方法。 您可以做的唯一方法是遍歷列表。

for i in range(len(list_of_DataFrames)):
    list_of_DataFrames[i].to_excel("pathTo/ExcelFile-{}.xlsx".format(i))
for i, df in enumerate([df_1, df_2, df_n, ...]): df.to_excel(f"pathTo/ExcelFile_{i}.xlsx")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM