I am trying to filter a data set using the scipy.signal.savgol_filter
function, but I get the error
TypeError: expected x and y to have same length
when I try to assign the data in a new list.
What is stranger is that just before my last computation everything worked as intended, but now I get this. I have tried to create an empty list the size of the filtered one, but I get the same error.
Here is that part of my code:
import scipy as sc
import scipy.signal
Cf = sc.signal.savgol_filter(x=C, window_length=299, polyorder=3)
where C
is a well defined list of float type numbers.
I get the error that you reported if the window_length
is greater than the length of C
(e.g. savgol_filter([3, 1, 4, 1, 5, 9], window_length=7, polyorder=3)
).
In SciPy 1.0.0, the cryptic error message has been replaced with a more informative message:
ValueError: If mode is 'interp', window_length must be less than
or equal to the size of x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With