I have the following df
that ranks players by week (represented by each column)
1 2 3 4
0 Bob Jim Pam Pam
1 Amy Amy Jim Bob
2 Jim Bob Bob Amy
3 Pam Pam Amy Jim
For example, Bob
ranks 1st in week 1, 3rd in week 2, etc... I would like to turn this df
into a dictionary that consists of a list of numeric ranks (ie the index value for each week) for each player, like so:
{'Bob': [1,
3,
3,
2],
'Jim': [3,
1,
2,
4],
'Pam': [4,
4,
1,
1],
'Amy': [2,
2,
4,
3]}
I know I can do something with index
to get each team's index for each week, but first I would need to
- Shift the index so it starts at 1 (I was able to do this with
df.index += 1
) - Make a key for each team with the value pair being a list of their ranks
I am pretty stumped on part 2 but there has to be a pretty simple solution to this that I am missing. Any help would be appreciated. Thanks!