Here's my dtaset
Id Website Rank
1 facebook 25
2 facebook 5
3 line 9
What I want is only keep the lowest rank
Id Website Rank
2 facebook 5
3 line 9
Here's my dtaset
Id Website Rank
1 facebook 25
2 facebook 5
3 line 9
What I want is only keep the lowest rank
Id Website Rank
2 facebook 5
3 line 9
Try this
df = pd.DataFrame({'Id': [1, 2, 3],
'Website': ['facebook', 'facebook', 'line'],
'Rank': [25, 5, 9]})
# index the min ranks of each website
df.loc[df.groupby('Website')['Rank'].idxmin()]
Id Website Rank
1 2 facebook 5
2 3 line 9