I have a data frame like:
customer spend hurdle A 20 50 A 31 50 A 20 50 B 50 100 B
One way would be the below code. But it's a really inefficient and inelegant one-liner.
df1.groupby('customer').apply(lambda x: (x['spend'].cumsum() *(x['spend'].cumsum() > x['hurdle']).astype(int).shift(-1)).fillna(x['spend']))