df.head()
Player Tourn Score
Tom a 65
Henry a 72
Johno a 69
Ingram a 79
Ben a 76
Harry a 66
Nick b 70
Ingram b 79
Johno b 69
I have a dataframe of player scores in a variety of tournaments('a' to 'm'). Some players played in multiple tournaments, some players played in only one tournament. I wish to create an additional column for every player with a 1 if the player played in that tournament and a 0 if he didn't (so basically a dummy variable).
To look something like this (repeated for every player):
Player Tourn Score Tom(Dummy)
Tom a 65 1
Henry a 72 1
Johno a 69 1
Ingram a 79 1
Ben a 76 1
Harry a 66 1
Nick b 70 0
Ingram b 79 0
Johno b 69 0
What is the best way to achieve this in code? (Ideally I need something that scales well across large dataframes!)
Interested to hear your replies.