I am calculating the value for the Total ‘1st’ Position column (table below) and would like to do this using multiple conditions.
I want Total ‘1st’ Position to reflect the number of times a given athlete has won a race (as of a given day).
For example... see below that Steve's Total 1st Position increments by 1 when: Athlete = Steve and Position = 1. I want to do this for all athletes.
I have tried the following...
df['Total 1st Position'] = ((df['Position'] == '1') & (df['Athlete'] == df['Athlete'])).cumsum()
...but this only returns a running sum of the number of times df['Position'] == '1'
What am I doing wrong?