With Pandas, for the following data set
author1,category1,10.00
author1,category2,15.00
author1,category3,12.00
author2,category1,5.00
author2,category2,6.00
aut
import pandas as pd
df = pd.read_csv("in.csv", names=("Author","Cat","Val"))
print(df.groupby(['Author'])['Val'].max())
To get the df:
inds = df.groupby(['Author'])['Val'].transform(max) == df['Val']
df = df[inds]
df.reset_index(drop=True, inplace=True)
print(df)
Author Cat Val
0 author1 category2 15
1 author2 category4 9
2 author3 category1 7
3 author3 category3 7