无法使用pandas.read_excel覆盖数据

时间:2019-06-24 15:54:57

标签: python excel python-3.x pandas

此用于写入空单元格的代码有效:

fn = r'..\\..\\Decision Tree Classifier  TPS\\Decision Tree Classifier  TPS\\TestData.xlsx'    
df = pd.read_excel(fn, header=None)
df2 = pd.DataFrame({'Data': [7]})     
writer = pd.ExcelWriter(fn)
df.to_excel(writer, header=None, index=False)
df2.to_excel(writer, startcol=4,startrow=1, header=None, index=False)

writer.save()

enter image description here

此用于写入当前保存日期的单元格“ C2”的代码不:

fn = r'..\\..\\Decision Tree Classifier  TPS\\Decision Tree Classifier  TPS\\TestData.xlsx'
df = pd.read_excel(fn, header=None)    
df2 = pd.DataFrame({'Data': [7]}) 
writer = pd.ExcelWriter(fn)
df.to_excel(writer, header=None, index=False)

#change is located here
df2.to_excel(writer, startcol=3,startrow=1, header=None, index=False)

writer.save()

enter image description here

我该如何使用它?谢谢!

0 个答案:

没有答案