sum the 3 largest integers in groupby by 'stname' and 'county_pop',df.groupby('STNAME')['COUNTY_POP'].agg(lambda x: x.nlargest(3).sum())