Here's a loop based way to do it. I'd be excited if someone else has a way that better makes use of pandas.
import pandas as pd
data = {'Event': ['Start','Going','Stop','Start','Stop','Start','Start','Going','Going','Going','Stop','Stop','Start','Stop']}
df = pd.DataFrame(data)
cycle = 0
new_cycle = True
cycles = []
for x in df.Event:
if new_cycle and x == 'Start':
new_cycle = False
cycle += 1
elif x == 'Stop':
new_cycle = True
cycles.append(cycle)
df['cycles'] = cycles
print(df)
Output
Event cycles
0 Start 1
1 Going 1
2 Stop 1
3 Start 2
4 Stop 2
5 Start 3
6 Start 3
7 Going 3
8 Going 3
9 Going 3
10 Stop 3
11 Stop 3
12 Start 4
13 Stop 4
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…