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