python pandas, DF.groupby().agg(), column reference in agg()
agg is the same as aggregate. It’s callable is passed the columns (Series objects) of the DataFrame, one at a time. You could use idxmax to collect the index labels of the rows with the maximum count: idx = df.groupby(‘word’)[‘count’].idxmax() print(idx) yields word a 2 an 3 the 1 Name: count and then use loc … Read more