[ad_1]
You can use numpy masking and itertools.groupby.
from itertools import groupby
b = 6
sum(len(list(g))>=2 for i, g in groupby(a < b) if i)
#3
[ad_2]
solved Count the number of times elements in a numpy array consecutively satisfy a condition