I need to subset a large DataFrame into smaller ones specific to a name in the "Name" Column. The Names will be different each time so I took the unique values from the "Name" column and put them in a list. I was hoping to be able to use the list to subset the data. Since the names will be different each time I tried using the groupby
function but I get a dictionary of DataFrames, however I need to be able to manipulate these further and save them as CSV files.
I have a DataFrame similar to this one:
data = {'Val':[8, 5, 6, 11, 33, 453, 332, 648], 'Word':["woo", "tang", "clan", "aint", "nothing", "to", "****", "with"], 'Name':["Eddie", "Jake", "Susannah", "Roland", "Roland", "Jake", "Jake", "Jake"]}
df = pd.DataFrame(data)
Val Word Name
0 8 woo Eddie
1 5 tang Jake
2 6 clan Susannah
3 11 aint Roland
4 33 nothing Roland
5 453 to Jake
6 332 **** Jake
7 648 with Jake
And I need to subset the data based on the 'Name' column to get 4 different DataFrames like these:
df_Jake
1 5 tang Jake
5 453 to Jake
6 332 **** Jake
7 648 with Jake
df_Roland
3 11 aint Roland
4 33 nothing Roland
df_Eddie
0 8 woo Eddie
df_Susannah
2 6 clan Susannah