calculating the number of specific consecutive equal values in a vectorized way in pandas,df['in'].groupby((df['in'] != df['in'].shift()).cumsum()).cumsum()