def roll(df): bear_fractal = df['high'].rolling(5, center=True).apply(lambda x: x[2] == max(x), raw=True) bull_fractal = df['low'].rolling(5, center=True).apply(lambda x: x[2] == min(x), raw=True) return bear_fractal, bull_fractal