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