arr = df.a.values
mask1 = np.hstack((False, arr[1:] < arr[:-1], False))
mask2 = mask1 & ~binary_closing(~mask1, [1, 1])
final_mask = mask2[1:] > mask2[:-1]
out = list(df.b[final_mask])
How to efficiently get indices of rows of DataFrame, where these rows meet certain cumulative criteria?