When I try to save these three dataframes to excel is corrupts somehow and I dont know why. The weird part is that the exact same code works perfectly in .ipynb format but does this in .py
The error message from Excel looks like this
Excel cannot open the file "myfile.xlsx' because the file format or the file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
My code looks like this
with pd.ExcelWriter("C:/path/to/folder.xlsx") as writer:
a_df.to_excel(writer, sheet_name="a", index=False)
b_df.to_excel(writer, sheet_name="b", index=False)
c_df.to_excel(writer, sheet_name="c", index=False)
Why? and how can this be fixed/avoided?