I have a time series with a cyclic/seasonal component. For each cycle, I am trying to figure out the slope and intercept of the highlighted section in red.
I have tried to define each cycle as 0, 1 .... n. But was unable to segment each cycle.
total = []
for index, row in df.iterrows():
total.append(row['top'])
cycle = []
for i in range(len(total)):
if total[i+1] < total[i] - 4:
cycle = cycle.append([i])
else:
cycle = i + 1

