All problems
Weather Feature Lag
Problem
Shift a weather feature series forward by lag: return temperatures[:n-lag].
For lag <= 0 return a copy unchanged; return an empty list when lag is at least the series length. Weather effects on demand are usually delayed.
Hint
The lagged feature at time t is the weather observed lag periods earlier.
Test cases
case 1
in: [[10,11,12,13],1]
expected: [10,11,12]
case 2
in: [[10,11,12],2]
expected: [10]
case 3
in: [[1],2]
expected: []
case 4
in: [[1,2],0]
expected: [1,2]
Starter codePython
def weather_feature_lag(temperatures, lag):
# Your code here
pass4 test cases · run your code against them in the editor