Q:

Drop rows with repeating NaN values in Pandas beyond a threshold

Is there a way to drop rows with NaN values only beyond a certain threshold for repetition?
For example, let's say we want the threshold of consecutive rows to be four. The following example with six consecutive rows with NaN values would have all six rows dropped.
start                        value                
2018-03-11 09:00:00+00:00    0.8
2018-03-11 09:15:00+00:00    0.0
2018-03-11 09:30:00+00:00    NaN
2018-03-11 09:45:00+00:00    NaN
2018-03-11 10:00:00+00:00    NaN
2018-03-11 10:15:00+00:00    NaN
2018-03-11 10:30:00+00:00    NaN
2018-03-11 10:45:00+00:00    NaN
2018-03-11 11:00:00+00:00    1.0
2018-03-11 11:15:00+00:00    1.6
2018-03-11 11:30:00+00:00    0.8

But the following example would have no rows dropped.
start                        value                
2018-03-11 09:00:00+00:00    0.8
2018-03-11 09:15:00+00:00    0.0
2018-03-11 09:30:00+00:00    0.0
2018-03-11 09:45:00+00:00    0.8
2018-03-11 10:00:00+00:00    NaN
2018-03-11 10:15:00+00:00    NaN
2018-03-11 10:30:00+00:00    NaN
2018-03-11 10:45:00+00:00    NaN
2018-03-11 11:00:00+00:00    1.0
2018-03-11 11:15:00+00:00    1.6
2018-03-11 11:30:00+00:00    0.8

Thanks!

A:

Using diff with ne cumsum create the group key , then we doing the Boolean slice. 
n=4
s=df.value.isnull().groupby(df.value.isnull().astype(int).diff().ne(0).cumsum()).transform('count')
df.loc[~((s>n)&(df.value.isnull()))]
Out[69]: 
                       start  value
0   2018-03-1109:00:00+00:00    0.8
1   2018-03-1109:15:00+00:00    0.0
8   2018-03-1111:00:00+00:00    1.0
9   2018-03-1111:15:00+00:00    1.6
10  2018-03-1111:30:00+00:00    0.8

