Issue
I want to append the contents of a panda dataframe df
to an excelsheet.
This is what I did;
df.to_excel(excel_writer="target.xlsx", sheet_name="sheet_1")
The problem with this code is that it overwrites target.xlsx
. I lost all my old data in target.xlsx
as a result. What I want the code to do is to append, not overwrite the excel sheet.
I am using python 3.7.
Solution
with pd.ExcelWriter('target.xlsx', mode='a') as writer:
df.to_excel(writer, sheet_name='sheet_1')
Source: Pandas Dataframe to Excel
Answered By - kaushik karan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.