All problems
Seasonal Shift Detect
Problem
Detect a change in the seasonal pattern. Split the series in half, average each season position (index modulo period) within each half, and return True when any position's mean differs by more than threshold between the halves.
Return False for invalid periods or when the series is shorter than two full periods.
Hint
Comparing per-position means isolates a change in seasonality from a level shift.
Test cases
case 1
in: [[1,5,1,5,1,5,1,5],2,0.5]
expected: false
case 2
in: [[1,2,1,2,5,6,5,6],2,1]
expected: true
case 3
in: [[1,2,3,4],2,10]
expected: false
case 4
in: [[1,2,1,2,3,4,3,4],2,0.5]
expected: true
Starter codePython
def seasonal_shift_detect(series, period, threshold):
# Your code here
pass4 test cases · run your code against them in the editor