I have two columns name as month_return1
and month_return2
: I want to find if month_return1 is greater than month_return2 or not, and if yes since how many rows is it greater. Somewhat like a streak maybe which tells a number (Ex. 3, which means month_return1 > month_return2 since last 3 values.) .
Here is the data I am working on :
Example explanation - For the first five rows the streak will go as 1,2,3,4,5 and at 5th row the number would be 5. On row 6 the counter resets as month_return2 is not greater than month_return1 so it's gonna show 0 or NA till it again finds month_return1 > month_return2
.
Hope I'm able to explain properly. Thanks.