I have a bunch of data frames with sales data for different brands. I want to create a function that ultimately makes excel files from the brand specific data frames. Everything works fine except I need to make uniquely named excel files as the output. Here is what I currently have:
def brandOverview(b):
brandWriter = pd.ExcelWriter("Brand.xlsx", engine='xlsxwriter')
b.to_excel(brandWriter, sheet_name='Data')
brandWriter.save()
This works, but ultimately I would like "Brand.xlsx" to be uniquely named for the data frame that is put into the function (b). For example if my dataframe was named "Adidas", brandOverview(Adidas) would output a file named "Adidas.xlsx".
I tried to use:
brandWriter = pd.ExcelWriter((str(b)+".xlsx"), engine='xlsxwriter')
From what I can decipher, this generated a string of all the data in the data frame, ultimately causing an error.