I need to find 'participant_id
' that have blocks of same elements (NaNs) of a certain length. For example, consider the following df
:
summary participant_id
13865 3.0 28
13995 NaN 28
14050 3.0 28
14219 5.0 28
14346 NaN 28
14364 4.0 28
14456 4.0 28
14680 NaN 28
14733 3.0 28
14913 2.0 28
15007 4.0 28
15107 4.0 28
15280 NaN 28
15287 3.0 28
15420 2.0 28
15521 2.0 28
15756 NaN 28
15758 3.0 28
15973 NaN 28
16038 4.0 28
16079 6.0 28
16215 4.0 28
16412 NaN 28
16506 6.0 28
16543 6.0 28
16649 2.0 28
16811 NaN 28
16911 NaN 28
16928 3.0 28
17028 2.0 28
11582 NaN 27
11718 2.0 27
11843 NaN 27
11941 2.0 27
12053 NaN 27
12142 NaN 27
12269 NaN 27
12367 4.0 27
12510 NaN 27
12632 NaN 27
12732 NaN 27
12796 2.0 27
12946 NaN 27
13059 NaN 27
13126 2.0 27
13312 NaN 27
13394 3.0 27
13427 2.0 27
13618 NaN 27
13707 NaN 27
13832 NaN 27
13945 NaN 27
14087 NaN 27
14199 NaN 27
14299 NaN 27
14398 NaN 27
14520 NaN 27
14639 NaN 27
14759 NaN 27
14897 NaN 27
15013 NaN 27
15116 NaN 27
15182 3.0 27
15319 NaN 27
15437 NaN 27
15518 3.0 27
15695 NaN 27
15812 NaN 27
15821 2.0 27
15933 2.0 27
If Im interested in blocks of more than 4 consecutive NaNs, than the only option will be participant_id = 27
, if I want blocks_length = 2
, than the answer will be participant_id = [27,28]
I was trying to follow similar solution, but it didn't work.