0

I want to get a total number of medals earned column per athlete instead of having duplicate rows for an athlete per type of medal earned.

Athlete | Gold | Bronze | Silver
Tim     | 1    | 0      | 0    
Tim     | 0    | 0      | 1  
Joe     | 1    | 0      | 0

df.groupby('Athlete').first().reset_index()

This isn't working, It's just combining duplicates and dropping medals instead of summing them to the athlete.

1 Answers1

0

Maybe this is what you need?

df.groupby('Athlete').sum()

The output:

Athlete Gold    Bronze  Silver          
Joe        1         0       0
Tim        1         0       1