Reputation: 51
sm.tsa.seasonal_decompose(Train['Count'],period=30).plot)
result = sm.tsa.stattools.adfuller(train.Count)
plt.show()
help me to solve this error!!
i tried this in an ml based traffic project but its not working and showing value error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-41-70db076f167d> in <module>
----> 1 decomposition = sm.tsa.seasonal_decompose(Train['Count'], period =30).plot()
2 result = sm.tsa.stattools.adfuller(train.Count)
3 plt.show()
~\miniconda3\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
197 else:
198 kwargs[new_arg_name] = new_arg_value
--> 199 return func(*args, **kwargs)
200
201 return cast(F, wrapper)
~\miniconda3\lib\site-packages\statsmodels\tsa\seasonal.py in seasonal_decompose(x, model, filt, period, two_sided, extrapolate_trend)
130
131 if not np.all(np.isfinite(x)):
--> 132 raise ValueError("This function does not handle missing values")
133 if model.startswith('m'):
134 if np.any(x <= 0):
ValueError: This function does not handle missing values
Upvotes: 5
Views: 4770
Reputation: 71
In numpy documentation says about the isfinite
function:
Test element-wise for finiteness (not infinity and not Not a Number). The result is returned as a boolean array.
Let's try to check result for our df:
import numpy as np
np.isfinite(df['value'])
index | value |
---|---|
0 | True |
1 | False |
2 | True |
3 | True |
4 | True |
One of values returns False, we can find it:
df[df.index.isin(np.isfinite(df[['value']]).query('not value').index)]
And we can fill empty values:
df['value'] = df['value'].fillna(0)
Now, it will work:
seasonal_decompose(df['value'])
Upvotes: 7