ii = df[pd.notnull(df.C)].index
dd = np.diff(ii)
jj = [ii[i] for i in range(1, len(ii)) if dd[i - 1] > 2]
jj = [ii[0]] + jj
for ci in jj:
    df.C.values[ci:ci + 3] = 1.0
pandas replace only part of a column