I want get consecutive length labeled data
a b
---
1 1
0 2
1 3
1 2
0 1
1 3
1 1
1 3
0 3
1 2
1 1
I want :
a b | c
--------
1 1 1
0 2 0
1 3 2
1 2 2
0 1 0
1 3 3
1 1 3
1 3 3
0 2 0
1 2 2
1 1 2
then I can calculate the mean of "b" column by group "c". tried with shift and cumsum and cumcount all not work.