Home > Back-end >  save data to new worksheet, in existing workbook using python
save data to new worksheet, in existing workbook using python

Time:03-13

created a new dataframe named df3 and saved to excel workbook named masterdata.xlsx, later created another dataframe named table when I try to write that dataframe to sheet2 of masterdata.xlsx, it overrighted the first created dataframe.

masterdata.xlsx have two sheets, sheet1 and sheet2. sheet1 have some data. how to save newly created dataframe table to sheet2 without losing sheet1 using python.

CodePudding user response:

You need to create pandas excel writer and then save on different sheets like this:

df1.to_excel(writer, sheet_name='Sheet1')
df2.to_excel(writer, sheet_name='Sheet2')
  • Related