how save second sheet in excel using python 1

how save second sheet in excel using python

writer2 = pd.ExcelWriter('mult_sheets_2.xlsx')

df_1.to_excel(writer2, sheet_name = 'df_1', index = False)
df_2.to_excel(writer2, sheet_name = 'df_2', index = False)

writer2.save()

Here is what the above code is Doing:
1. We create a writer object, which is a pd.ExcelWriter object.
2. We then use the to_excel() method to write each dataframe to a different sheet.
3. We then save the writer object using the save() method.

Similar Posts