Let's say we have a pandas dataframe like the one below.
> category level score > Bus travel 0.75 > Bus travel 0.60 > Bus vehicles 0.50 What I want is to group by the 'level' and calculate the 'count' and the maximum score for each 'level'. Also the 'hard' part is to create an output like this:
> category travel score vehicles score > Bus 2 0.75 1 0.5 I have been trying doing this:
> grouped = df.groupby('level').agg( { 'category': 'count', 'score': 'max' }) Any ideas?