作者Kuba4ma ()
看板Python
标题[问题] excel写入问题
时间Sat Mar 14 00:15:30 2020
我需要先读取同一份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://webptt.com/cn.aspx?n=bbs/Python/M.1584116132.A.55F.html
※ 编辑: Kuba4ma (101.12.16.155 台湾), 03/14/2020 00:16:09
1F:推 fiorentino: 程式码不完整 03/14 00:57
2F:→ fiorentino: 看不出来是用哪一个套件 03/14 00:57
3F:推 yiche: xlsxwriter ? 03/14 01:38
抱歉 已补上
※ 编辑: Kuba4ma (117.19.195.252 台湾), 03/14/2020 09:22:25
4F:推 yiche: writer = pandas.Excelwriter 03/14 12:30
5F:→ yiche: data frame.to_excel(writer, sheet_name=‘?’) 03/14 12:30
7F:→ hongyan: 我要写入的是一个dataframe list,当然你只有两个df,就 03/14 13:06
8F:→ hongyan: with底下个别key两个df.to_excel就好 03/14 13:07
9F:→ hongyan: sheet_name参数 key你要写入的sheet名就好 03/14 13:12