I have the following data:
Date, Symbol, Close2021-01-01, AAPL, 102021-01-02, AAPL, 122021-01-03, AAPL, 32021-01-01, MSFT, 122021-01-02, MSFT, 202021-01-03, MSFT, 122021-01-04, MSFT, 12021-01-05, MSFT, 22021-01-06, MSFT, 3
I'd like to count the number of rows it takes until the next 'Close' value is less than the current row 'Close' value within the 'Symbol' group
My goal is to understand how many days it takes to get a lower price.
Expected Output
Date, Symbol, Close, Output2021-01-01, AAPL, 10, 22021-01-02, AAPL, 12,12021-01-03, AAPL, 3, NaN2021-01-01, MSFT, 12, 32021-01-02, MSFT, 20, 12021-01-03, MSFT, 12, 12021-01-04, MSFT, 1, NaN2021-01-05, MSFT, 2, 12021-01-06, MSFT, 1, NaN