I have my code that looks like the following as part of a long loop structure that writes 2 dfs to the same spreadsheet and excel tab. Here is the code I'm using trying to append with each write sequence:
# WRITE OUTPUT TO EXCEL FILE -
with pd.ExcelWriter('\\\porfiler03\\gtdshare\\ERA5-MAPPING\\PCA\\PCA_ERA5_output.xlsx', engine="openpyxl", mode="a") as writer:
w.to_excel(writer, sheet_name=sheet)
with pd.ExcelWriter('\\\porfiler03\\gtdshare\\ERA5-MAPPING\\PCA\\PCA_ERA5_output.xlsx', engine="openpyxl", mode="a") as writer:
finalpcs.to_excel(writer, sheet_name=sheet,startrow=5)
My result, however, has the df1 ("w") written to one worksheet tab (14) followed by the next df ("finalpcs") written to a new worksheet tab (141). I need them both written to the same worksheet tab - "14". I've tried to use "startrow" for the second df to not overwrite the first write of df "w".
Here is a pic of the first save sequence:
And, after the second save sequence:
thank you,


to_excelis just a helper. It's not a fully flexible Excel editing solution. You COULD, for example, useto_excelon your big list, then use a module likexlsxwriterto modify it.