Best way to split a DataFrame given an edge,df.groupby((df.a == 'B').shift(1).fillna(0).cumsum())