使用season_decompose时出现此错误
from statsmodels.tsa.seasonal import seasonal_decompose
decomposition = seasonal_decompose(ts_log)
这给出了这个错误:
TypeError: 'numpy.float64' object cannot be interpreted as an index
ts_log是一个时间序列
ts_log.index.dtype
dtype('<M8[ns]')
和
ts_log.head()
Month
1949-01-01 4.718499
1949-02-01 4.770685
1949-03-01 4.882802
1949-04-01 4.859812
1949-05-01 4.795791
Name: #Passengers, dtype: float64
ts_log.index
DatetimeIndex(['1949-01-01', '1949-02-01', '1949-03-01', '1949-04-01',
'1949-05-01', '1949-06-01', '1949-07-01', '1949-08-01',
'1949-09-01', '1949-10-01',
...
'1960-03-01', '1960-04-01', '1960-05-01', '1960-06-01',
'1960-07-01', '1960-08-01', '1960-09-01', '1960-10-01',
'1960-11-01', '1960-12-01'],
dtype='datetime64[ns]', name=u'Month', length=144, freq=None)
将#Passengers转换为int也会产生相同的错误