Skip to content
Advertisement

Tag: calculated-columns

Pandas: calculate first purchase amount

I need to calculate the first purchase amount for every client. This is my code: ticket.groupby([‘user_reference_id’,’total_amount’]).reference_date.min().reset_index()“ And i have this result: user_reference_id total_amount reference_date* enter image description here I need it grouped by user_reference_id with the minimum reference_date (first date when a customer made the purchase) and corresponding total_amount. In this case i need the next output: reference_date 2019-06-14, user_reference_id

Advertisement