I have a pandas DataFrame like this:
>>> df = pd.DataFrame({'MONTREGL':[10,10,2222,35,200,56,5555],'SINID':['aaa','aaa','aaa','bbb','bbb','ccc','ccc'],'EXTRA':[400,400,400,500,500,333,333]})
>>> df
MONTREGL SINID EXTRA
0 10 aaa 400
1 10 aaa 400
2 2222 aaa 400
3 35 bbb 500
4 200 bbb 500
5 56 ccc 333
6 5555 ccc 333
I want to sum the column MONTREGL
for each groupby SINID
...
So I get 2242 for aaa and so on... ALSO I want to keep the value of column EXTRA
.
This is the expected result:
MONTREGL SINID EXTRA
0 2242 aaa 400
1 235 bbb 500
2 5611 ccc 333
Thanks for your help in advance!