[英]How to store multiple files (two list and a df) by pickle in python 2.7
[英]How to save a df into two excel files in multiple locations?
我試圖保存在兩個不同的文件夾(output1,output2)中生成的excel文件
我嘗試了這個,沒有工作
writer = pd.ExcelWriter([output1,output2], engine='xlsxwriter')
df1.to_excel(writer, sheet_name='sheeta', index = None)
謝謝
您可以使用如何在Python中復制文件來復制文件? 創建一次之后 ...或只需編寫兩次即可:
import pandas as pd
output1 = "p.xlsx"
output2 = "q.xlsx"
df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})
for o in [output1,output2]:
writer = pd.ExcelWriter(o, engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')
writer.save()
結果將寫入2個文件,其中包含數據:
Doku:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.