I am trying to re-write this for loop into a function to make it applicable to different time series. It is pretty straightforward but for some reason there are errors with the function. The goal is to subtract the current value with its preceding one:
Asked
Active
Viewed 27 times
1 Answers
1
append doesn't return the modified list, it modifies it in place. This means that
diff = diff.append(value)
will be assigning None to diff, causing your problem.
You just need
diff.append(value)
as you had in the original loop.
Kemp
- 2,802
- 1
- 14
- 26