I have a pandas dataframe with donation information, example below:
DonorID DonationID Date Amount
a1234 3767 1/1/2019 $100
a1234 2193 2/1/2019 $50
a1234 0915 3/1/2019 $75
b5678 4562 5/1/2019 $45
b5678 8965 4/1/2019 $80
I'm using the groupby function to calculate the total per DonorID and min date but would also like to calculate the amount of the earliest donation and DonationID by DonorID.
df2 = df1.groupby(['DonorID'], as_index=False ).agg( {'Amount':sum,'Date':min})
Current output is:
DonorID Amount Date
a1234 $225 1/1/2019
b5678 $125 4/1/2019
The desired output would be along the lines of:
DonorID Amount Date First Gift Amount DonationID
a1234 $225 1/1/2019 $100 3767
b5678 $125 4/1/2019 $80 8965
Any help would be greatly appreciated!