首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用statsmodels.tsa.seasonal的TypeError

使用statsmodels.tsa.seasonal的TypeError
EN

Stack Overflow用户
提问于 2017-09-27 01:01:36
回答 1查看 1K关注 0票数 0

我在试着分解一个时间序列。我的date不包含Nan和inf,它的索引是'datetime64ns。但由于某些原因,我无法理解,运行以下命令:

代码语言:javascript
复制
statsmodels.tsa.seasonal.seasonal_decompose(data, model='additive',filt=None, freq=None, two_sided=True)

出现以下错误:

代码语言:javascript
复制
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''

我的数据如下所示:

代码语言:javascript
复制
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

我从一个数据框中获得了这个系列:

代码语言:javascript
复制
    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

使用以下代码:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2018-04-17 22:31:28

这里也有同样的问题。

检查类型是否为整数。如果不是,则将其转换。

代码语言:javascript
复制
data.dtypes
dtype('int32')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46432096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档