2021-12-03

Python DataFrame how to get all rows with the same name and add the values together

When I search for my problem all I keep finding is grouping the same values together but I am looking to get the value of each team and add them together

Eg this is my Dataframe

0   Liverpool        4        
1   West Ham         0
2   Bournemouth      1
3   Burnley          3
4   Crystal Palace   0
5   Liverpool        6
6   West Ham         2
7   Bournemouth      8
8   Burnley          1
9   Crystal Palace   4

All the examples I see online is just grouping them together

eg

0   Liverpool        4 
1   Liverpool        5       
2   West Ham         2
3   West Ham         1
4   Crystal Palace   4
5   Crystal Palace   1

but what I am after is in order of high to low

0   Liverpool        9 
1   Crystal Palace   5
2   West Ham         3

enter image description here



from Recent Questions - Stack Overflow https://ift.tt/3DbSXe4
https://ift.tt/3DdyTIz

No comments:

Post a Comment