pandas – grouping ids of each repeatable class and putting them in a list in a column

You can use the groupby and agg:

df.groupby("repeat").agg(lambda x: list(x)).reset_index()

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top