I'm new to pandas. I have a large excel file, what I’m trying to do is split the data frame after manipulation into multiple excel workbooks. There is more or less 400 vendors and I would like each To have their own named workbook.
Example. SallyCreative.xlsx, JohnWorks.xlsx, AlexGraphics.xlsx
Try the below code, I hope it will help and provide you the required solution.
Consider I have data like this.
displayName self created id field fromString
0 A A 2018-12-18 1 status Backlog
1 B B 2018-12-18 2 status Funnel
Now i want to create different excel display name as A.xlsx and B.xlsx.
We do so shown below:
import pandas as pd
data_df = pd.read_excel('./data_1.xlsx')
grouped_df = data_df.groupby('displayName')for data in grouped_df.displayName:grouped_df.get_group(data[0]).to_excel(data[0]+".xlsx")
This will generate excels for you as per the number of display name in this case.
But you can modify solution according to your need.
Hope this would help.
As asked in the comment by @Kpittman
We can save in any directory by giving path to that directory.
import pandas as pd
data_df = pd.read_excel('./data_1.xlsx')
grouped_df = data_df.groupby('displayName')for data in grouped_df.displayName:grouped_df.get_group(data[0]).to_excel("./IO/Files/"+data[0]+".xlsx")
So instead of this path ./IO/Files/
you can provide your custom path.
Hope it will help