I tried to save an excel file in azure databricks with a dynamic name:
import pandas as pd
#initialize the excel writer
writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')
#store your dataframes in a dict, where the key is the sheet name you want
frames = {'sheet_1': df_1, 'shet_2': df_2,
'sheet_3': df_3}
#now loop thru and put each on a specific sheet
for sheet, frame in frames.items(): # .use .items for python 3.X
frame.to_excel(writer, sheet_name = sheet)
#critical last step
writer.save()
Next I did it:
%sh
sudo mv test.xslx /dbfs/mnt/
It works but I would like to add the date to the name of the file:
test_2= 'test' + datetime.today().strftime("%d%m%y") + '.xlsx'
But I don't know how to do it with %sh