I have a Pandas dataframe with 1000s of rows. and it has the Names
column includes the customer names and their records. I want to create individual dataframes for each customer based on their unique names. I got the unique names into a list
customerNames = DataFrame['customer name'].unique().tolist()
this gives the following array
['Name1', 'Name2', 'Name3, 'Name4']
I tried a loop by catching the unique names in the above list and creating dataframes for each name and assign the dataframes to the customer name. So for example when I write Name3
, it should give the Name3
's data as a separate dataframe
for x in customerNames:
x = DataFrame.loc[DataFrame['customer name'] == x]
x
Above lines returned the dataframe for only Name4
as dataframe result, but skipped the rest.
How can I solve this problem?