I have a df I'd like to split into 5 (named df1 - df5) based on the value of one column (origin
). I've tried groupby
, and a few other things (like this and this) with no success.
My df looks like this
origin t_id Group ids ...
0 g2 300 group2 23, 54, 24 ...
1 g 300 group2 1, 89 ...
2 g3 300 group10 155, 4, 90 ...
3 g5 300 group11 38, 13, 45. ...
4 g4 300 group2 2. ...
Right now I have it broken up into multiple .loc
statements for each unique value of origin
, but there must be a cleaner, more concise way to do this.