df['categories'] = (df.groups != df.groups.shift()).cumsum()
f = {'start': ['first'], 'end': ['last'], 'groups': ['first']}
return df.groupby('categories').agg(f)

def b(d):
    bins = [-1, 0, 1, 5, 10, 15, 100]
cut_ser = pd.cut(d['height'], bins=bins)
return d.groupby([(cut_ser.shift() != cut_ser).cumsum(), cut_ser]).agg({
    'start': 'first', 'end': 'last'}).reset_index(level=1).reset_index(drop
    =True).rename(columns={'height': 'height_grouped'})
print(a(df))
print(b(d))
Pandas - group by consecutive ranges