Pandas: find nearest higher high (OHLC)
问题 I'm trying to find the fastest solution to iterate over each row of Open High Low Close data and count out how many rows exist between the current row's high and the next high that’s greater than or equal to the original. Here is a shortened code example which I think explains it well (I'd be trying to find the final value of _next ): for i in df.index: while df.loc[i, 'high'] > df.loc[_next, 'high']: _next += 1 I think I need to use a lambda function inside apply but I can't seem to get it