I'm trying to replace a list of existing values within a pandas column.
team ID ... win
0 1 ... 8
1 1 ... 4
2 3 ... 5
3 4 ... 2
4 5 ... 1
(team IDs can repeat and are not unique)
I'm looking to change the team ID to team names from an existing list that I already have
team_names = ['A', 'B', 'C', 'D']
I was previously doing it like this:
df.name = df.name.replace({
1: 'A',
2: 'B',
3: 'C',
4: 'D'
})
However, the issue i'm facing now is that the two lists I want to map between is almost 100. So I was wondering if anyone could share a faster method of doing this?