Giving the following column
Name | score1 | score2 | score3 |
---|---|---|---|
Bob | 100 | 120 | 900 |
Lisa | 40 | 120 | 90 |
Bob | 590 | 490 | 80 |
Tim | 100 | 120 | 900 |
Tim | 40 | 120 | 90 |
Bob | 590 | 490 | 80 |
I would like to calculate the average of all columns, for each person in the Name column. So for Bob, I would like to get one average of all 9 values.
I know that the code below will calculate the average of multiple columns. How can I make it calculate the average for all rows with the same name?
df['averages'] = df[['Score1', 'Score2', 'Score3']].mean(axis=1)