df['lablel']=df.extension.diff()#Find the difference between consecutive ros in the column extension
df['lablel']=(df.lablel.ge(0)&df.lablel.shift(1).le(0)|df.lablel.ge(0)&df.lablel.shift(-1).le(0)).cumsum()+1#Find zero crossing from the consecutive differences, cummulatively sum and add 1 to the outcome
extension lablel
0 0.000 1
1 0.050 1
2 0.100 1
3 0.150 2
4 0.130 2
5 0.080 2
6 0.020 2
7 0.050 3
8 0.075 3
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…