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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)