Hi I have a pandas df which contains dates and amounts.
Date Amount
0 10/02/22 1600
1 10/02/22 150
2 11/02/22 100
3 11/02/22 800
4 11/02/22 125
If an entry is one day later and less than 10% of any other entry I would like to sum the amounts and then take the earliest date.
So the df would look like:
Date Amount
0 10/02/22 1825
1 10/02/22 150
2 11/02/22 800
I've tried creating threshold and then creating groups based on these conditions but this does not yield expected results.
threshold_selector = (amount_difference < 0.1) & (date_difference == day)
Where day is a time delta of one day
groups = threshold_selector.cumsum()
dates= dates.groupby(groups).agg({'Amount':sum, 'Date': min})
The result is all rows joined into one.