I can't make a function for a column (df['contribution']
) where when it's greater than 0 (>0), you increment by 1 to calculate the number of times it's greater than 0. Thank you for your help
Asked
Active
Viewed 199 times
1

Paul Brennan
- 2,638
- 4
- 19
- 26

SLV
- 23
- 5
-
8`df['contribution'].gt(0).cumsum()`. – Quang Hoang Mar 23 '21 at 02:53
-
1Does this answer your question? [Cumsum Reset based on a condition in Pandas](https://stackoverflow.com/questions/53079313/cumsum-reset-based-on-a-condition-in-pandas) – Joe Ferndz Mar 23 '21 at 05:07
-
thanks for your help :) – SLV Mar 24 '21 at 23:36