# create a group-tag by every STOP
cond = df.SEG_DESC == 'STOP'
df['tag'] = cond.cumsum()
df.loc[cond, 'tag'] = df.loc[cond, 'tag'] - 1
# for every tag-group use back fillna
df['ID_START_STOP'] = df.groupby('tag')['ID_START_STOP'].bfill().astype(int)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…