I'm looking for a way to take a pandas Series and return new Series representing the number of prior, consecutive values that are higher/lower than each row in the Series:
a = pd.Series([30, 10, 20, 25, 35, 15])
...should output:
Value Higher than streak Lower than streak
30 0 0
10 0 1
20 1 0
25 2 0
35 4 0
15 0 3
This will allow someone to identify how important each "regional max/min" value is in a time series.
Thanks in advance.