I have a dataframe df
, where I need to find if some player_id
has changed its team
value along the season:
player_id team
1 Liverpool
2 Manchester
1 Liverpool
2 Manchester
1 Liverpool
2 Tottenham
To find duplicated pairs I would simply:
duplicate = df[df.duplicated(['player_id', 'team'])]
But the dataframe has duplicated pairs as a rule.
I need to find all cases when one player_id has more than one team, and print:
2
How so?