I have an excel file with 6 sheets, in one of sheets I would like to a append data some data but keep the other sheets intact.
I have the following code
import pandas as pd
xls = pd.ExcelFile('myfile.xlsx')
df1 = pd.read_excel(xls, 'log')
d = {'Date': [2023], 'Time': [180855],'Q': ['2']}
df2 = pd.DataFrame(data=d)
df_final = pd.concat([df1,df2])
df_final.to_excel(xls, sheet_name='log')
So I specify the sheet and only interact with the sheet log
, however my new saved sheet only has the log
sheet saved and all other sheets deleted.
How do I prevent this?