def slice_consc(df, n):
    Acol = np.array(df['A'])
Acol_ext = np.concatenate(([0], (Acol == 0) + 0, [0]))
starts = np.where(np.diff(Acol_ext) == 1)[0]
stops = np.where(np.diff(Acol_ext) == -1)[0]
id = np.zeros(Acol.size + 2, dtype=int)
valid_mask = stops - starts >= n
id[stops[valid_mask]] = -1
id[starts[valid_mask] + 2] = 1
return df[(id.cumsum() == 1)[:-2]]
slice pandas df based on n consecutive instances of element