DataFrame:
B = pd.DataFrame({'b':['II','II','II','II','II','I','I','I'],
'MOST_FREQUENT':['1', '2', '2', '1', '1','1','2','2']})
I need to get the most frequent value in a column MOST_FREQUENT
for each group:
pd.DataFrame({'b':['I','II'],
'MOST_FREQUENT':['2','1']})
The only clue i found - mode()
, but is not applieble to DataFrameGroupBy
EDIT: I need a solution, which satisfies the pandas' .agg()
function