How to merge two rows into one?

Viewed 30

If I have the following table:

enter image description here

How can I merge two or more rows based on a specific column? In this case, it is column Col_4.

enter image description here

Thanks

1 Answers

A simple groupby with agg will do the trick

df.groupby(['Col_1','Col_2','Col_3'],as_index = False).agg(list)
Related