0

Suppose i have a df with a column X with the following unique values ('A', 'B', 'C')

I want to create a function that will create dataframes containing only the items for such unique value of column X. How best to do this?

I would usually write line of codes by filtering it but I want to know how best to manage this.

1 Answers1

1

Try this:

sub_dfs = [df[df['X']== i] for i in list(df['X'].unique())]