conditional replacement of row's values in pandas dataframe,df['SEQ'] = df.sort_values(by='START').groupby('ID').cumcount() + 1