0

same as the question, I want to firstly group different rows, if their first item in the row is the same, then fatten each columns in one group into a list.

my initial dataframe initial

and my target is like: target

the problem is that i cannot use simply df.groupby('key').apply(list) cause it will flatten column2 val1 and val2 together

Is there any way to do this?

0 Answers0