How to apply savgol_filter in python so that future data will not be read

Viewed 147

I am trying to make prediction of some data in python. I try to use scipy.signal.savgol_filter to smooth the data. However, If I dont understand it wrongly, if savgol_filter has a window of x, it will take future (x-1)/2 data points into account.

Is there a way to use the same smoothing method, but only take previous data into account?

I know we can do something like the following:

some_series.rolling(window_size).apply(some_regression_func)

But I have tried that and it is much slower than savgol_filter. Is there some faster or existing method to achieve this? Thanks a lot for reading this question.

0 Answers
Related