I generated a dataset that shows the similarity between users in a graph based on their neighbors. Based on a dataset that shows the trust relations between users in a social network, I'm aiming to build a new dataset that contains the most similar users to my "trustor" user (e.g. the 3 most similar ones) by using a similarity evaluation algorithm. I have listed the users in descending order so that the first time a new "trustor" appears, his/her most similar users appear at first.
new_trust.sort_values(['truster','value'],ascending=False)
So basically I need to keep only the 3 first appearances of each user in my dataframe.
I tried to do a for i in range(new_trust.len())
: but couldn't quite find it.