I have a problem that should not be so difficult, but it pounds me. There should be an easy way to do this. I have a series from a data frame that looks like this:
value 2001-01-04 0.134 2001-01-05 Nan 2001-01-06 Nan 2001-01-07 0.032 2001-01-08 Nan 2001-01-09 0.113 2001-01-10 Nan 2001-01-11 Nan 2001-01-12 0.112 2001-01-13 Nan 2001-01-14 Nan 2001-01-15 0.136 2001-01-16 Nan 2001-01-17 Nan
Iterating from bottom to top, I need to find the index of a value greater than 0.100 at the earliest date when the next earliest date is less than 0.100.
So, in the above series, I want to find the index of the value 0.113, which is 2001-01-09. The next earlier value is below 0.100 (0.031 in 2001-01-07). Two later values โโare greater than 0.100, but I want the index of the earliest value> 0.100 after the value is less than the threshold, iterating from bottom to top.
The only way I can do this is to reverse the series, iterate to the first (last) value, check if it is> 0.100, and then repeat the next earlier value again and check it to see than 0.100. If it's not me. If it is> 0.100, I need to repeat again and check the earlier number.
Undoubtedly, there is a non-dirty way to do this, I do not see to avoid this stepwise iteration.
Thanks in advance for your help.
source share