Notebook
#Group by WIkidata Q number and get highest score #create a helper column with max #dfScoreSPALitt['max'] = dfScoreSPALitt.groupby('wd')['score'].transform('max') #dfScoreSPALittMax = dfScoreSPALitt.groupby('wd')['max','spaid','FirstNameWD','LastNameWD','BirthYearWD']. \ # apply(lambda x: x.nlargest(1, columns=['score'])).sort_values(['max','wd'], ascending=False) #dfScoreSPALittMax #ss = dfScoreSPALitt.groupby('wd')['max','spaid','FirstNameWD','LastNameWD','BirthYearWD']. \ # apply(lambda x: x.nlargest(1, columns=['score'])).sort_values(ascending=False)