0

I have a dataframe like this :

ID  State  Qty
1   'UP'    2
1   'UP'    3
1   'AR'    1
2   'KJ'    3
4   'AP'    1
2   'KJ'    4

Here is what i need :

I want to sum the Qty values of multiple rows if both the values of ID and State columns are same for those rows and put them in a single row with the Qty value as sum .

So what I need is this :

ID  State  Qty
1   'UP'    5
1   'AR'    1
2   'KJ'    7
4   'AP'    1

How to do this efficiently ?

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125

0 Answers0