0

I have a dataframe in Panda with the number of cows stolen per Year :

    stolen_each_year = data[['stolen cows','year_of_date' ]]

I would like to remove all Duplicate years and keep just one with the sum of all. I have an idea with a python function but I am trying to use the panda at the maximum enter image description here

Thank You for your time

EDIT : I tried with the .groupby method but it does not seem to work fine After using the groupby method

Raphael00
  • 61
  • 1
  • 9

1 Answers1

2

You can groupby and then sum the stolen cows.

stolen_each_year.groupby("year_of_date")['stolen cows'].sum()


also... interesting dataset ...

modesitt
  • 7,052
  • 2
  • 34
  • 64