[問題] excel寫入問題

看板Python作者時間5年前 (2020/03/14 00:15), 5年前編輯推噓4(405)
留言9則, 3人參與, 5年前最新討論串1/1
我需要先讀取同一份excel的sheet1的第一行的資料 然後複製寫入同一份excel的sheet2的第一行 我目前只知道pandas要寫入是用data.to_excel的指令 但是這個好像是創一個新的excel並寫入 而我需要的是寫入同一份excel的sheet2的第一行 想請教有什麼指令可以做到我的需求 以下code的sheet_name=8是我內文講得sheet1 import pandas as pd data=pd.read_excel("C:/Python/data.xlsx",sheet_name=8) a=data.iloc[0,:] 寫到這邊就卡住了 麻煩大神們指點迷津 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.12.16.155 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1584116132.A.55F.html ※ 編輯: Kuba4ma (101.12.16.155 臺灣), 03/14/2020 00:16:09

03/14 00:57, 5年前 , 1F
程式碼不完整
03/14 00:57, 1F

03/14 00:57, 5年前 , 2F
看不出來是用哪一個套件
03/14 00:57, 2F

03/14 01:38, 5年前 , 3F
xlsxwriter ?
03/14 01:38, 3F
抱歉 已補上 ※ 編輯: Kuba4ma (117.19.195.252 臺灣), 03/14/2020 09:22:25

03/14 12:30, 5年前 , 4F
writer = pandas.Excelwriter
03/14 12:30, 4F

03/14 12:30, 5年前 , 5F
data frame.to_excel(writer, sheet_name=‘?’)
03/14 12:30, 5F

03/14 13:05, 5年前 , 6F

03/14 13:06, 5年前 , 7F
我要寫入的是一個dataframe list,當然你只有兩個df,就
03/14 13:06, 7F

03/14 13:07, 5年前 , 8F
with底下個別key兩個df.to_excel就好
03/14 13:07, 8F

03/14 13:12, 5年前 , 9F
sheet_name參數 key你要寫入的sheet名就好
03/14 13:12, 9F
文章代碼(AID): #1UQx6aLV (Python)
文章代碼(AID): #1UQx6aLV (Python)