Python Forum

Full Version: Saving Excel workbook file with dataframe names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Guys,
I am exporting multiple dataframes to excel template - GMC_template.xlsx which has formulas for further calculations. the below codes works well, when i am exporting the dataframes to each sheet of workbook but does not work when i export the dataframes to workbook template and save with dataframe name. error message -
Error:
save() takes 1 positional argument but 2 were given
could you assist me if this is right way to do it

dfs={"MAY":May_date,"JUN":June_date,"JUL":July_date,"AUG":Aug_date,"SEP":Sep_date,"OCT":Oct_date,"NOV":Nov_date,"DEC":Dec_date,
    "YTD":YTD,"Q3":Q3,"Q4":Q4,"HY2":HY2}
pth="Y:\\WEST\\2. BE\\4. MPM Belgium\\2020\\GMC Prep Automation\\Data_Prep_Python\\LEvsLY_Output\\"
Writer =pd.ExcelWriter("GMC_Template.xlsx", engine="xlsxwriter")

for dataset in dfs.keys():
    dfs[dataset].to_excel(Writer,index=False,startrow=1,startcol=19,header=False)

Writer.save(os.path.join(pth,dataset))