I have the following dataframe df:
data={\'id\':[1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2], \'value\':[2,2,3,2,2,2,3,3,3,3,1,4,1,1,1,4,4,1,1,1,1,1]}
#try this simpler version a= pd.Series([1,1,1,2,3,4,5,5,5,7,8,0,0,0]) b= a.groupby([a.ne(0), a]).transform('size').ge(3).astype('int') #ge(x) <- x is the number of consecutive repeated values print b