Slope and Intercept of each cycle/season of a time series

Viewed 39

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.

enter image description here enter image description here

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
0 Answers
Related