Home > database >  Summarising 2 columns
Summarising 2 columns

Time:04-14

So I'm not sure if I'll be explaining this question well, but As you can see in one columns there are counties and the other one is the number of herds and what I wanna do is the find out how many herds are in each country rather than counting how many times the county appears and than adding them all together. I hope it makes sense. If someone can share some function on how to do that, that would be wonderful, thank you!

df_image

CodePudding user response:

df.groupby('COUNTY')['NUMBER_OF_HERDS'].sum()
  • Related