0

I am wondering if there is a way to append data rather than make a list of data when doing something like a groupby().

What I am wanting to do is take a dataframe like this:

index NAME  ID  COLOR
0   Tim     1   red
1   Sally   2   red
2   Rob     3   green
3   Sally   2   blue
4   Sally   2   purple

And then merge the rows to make this:

index NAME  ID  COLOR1  COLOR2  COLOR3 
0   Tim     1   red
1   Sally   2   red     blue    purple
2   Rob     3   green

I know how to agg() with groupby() but am trying to figure out appending rather than making a list in a field, with this dataframe it would be a list in the COLOR field.

stefan_aus_hannover
  • 1,777
  • 12
  • 13

0 Answers0