此用于写入空单元格的代码有效:
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()
此用于写入当前保存日期的单元格“ 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()
我该如何使用它?谢谢!