Skip to content Skip to sidebar Skip to footer

Pandas Duplicates Groupby

I've a Pandas dataframe, and some numerical data about some people. What I need to do is to find people that appare more than one time in the dataframe, and to substitute all the r

Solution 1:

Use groupby + agg and define specific aggregation functions for each column as a dict like:

df.groupby('Names').agg({'Column1':'sum', 'Column2':'sum','Column3':'min'})

    Column1 Column2 Column3
Names           
Bob     3     3     2011
John    3     3     2005
Jonh    1     2     2016
Pier    1     1     2003

Post a Comment for "Pandas Duplicates Groupby"