0

I want to group the values by account and get summed rows but only where account is the same. I want a scalable version of it which can do this over 10,000 rows

What I have right now:

account  1      2
a       100     30
a       20      40
c       30      30
c       40      20 

What I want:

account 1     2
a       120   70
b       70    50
NotaCoder
  • 37
  • 4

1 Answers1

0

Use groupby + reset_index:

sums = df.groupby('account').sum().reset_index()

Output:

>>> sums
  account    1   2
0       a  120  70
1       c   70  50