Home > Net >  sum function not working in group by and aggregate function
sum function not working in group by and aggregate function

Time:04-28

collection file have 2,00,000 records having multiple account_no's.

collection_file = collection_file.astype({'coll_amt':'int'})
collection = collection_file.groupby(['account_no']).agg({'coll_amt':'sum','coll_date':'max','gs_date':'max'}).reset_index()

I am trying to aggregate values to find the sum of collection amount based on account_no. But it is not summing up the values.

CodePudding user response:

I tried recreating code based on your input. For me your above code is working as expected and summing the amount correctly . You sure you checking final output dataframe 'collection' and not any other dataframe?

enter image description here

  • Related