我在试着分解一个时间序列。我的date不包含Nan和inf,它的索引是'datetime64ns。但由于某些原因,我无法理解,运行以下命令:
statsmodels.tsa.seasonal.seasonal_decompose(data, model='additive',filt=None, freq=None, two_sided=True)出现以下错误:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''我的数据如下所示:
ds
2005-01-01 1.56832e+06
2005-02-01 1.77795e+06
2005-03-01 1.89924e+06
2005-04-01 2.19562e+06
2005-05-01 2.25281e+06
2005-06-01 2.20942e+06
2005-07-01 2.13806e+06
2005-08-01 2.15816e+06我从一个数据框中获得了这个系列:
y ds
ds
2005-01-01 1.56832e+06 2005-01-01 00:00:00
2005-02-01 1.77795e+06 2005-02-01 00:00:00
2005-03-01 1.89924e+06 2005-03-01 00:00:00
2005-04-01 2.19562e+06 2005-04-01 00:00:00
2005-05-01 2.25281e+06 2005-05-01 00:00:00使用以下代码:
df.columns = ['y','ds']
df[~df.isin([np.nan, np.inf, -np.inf]).any(1)]
df.index= df.ds
data = df.y #data is the time series I want to decompose系统信息: Python 3.5.1 | Pandas 0.20.3 |64位Windows 7
发布于 2018-04-17 22:31:28
这里也有同样的问题。
检查类型是否为整数。如果不是,则将其转换。
data.dtypes
dtype('int32')https://stackoverflow.com/questions/46432096
复制相似问题