TypeError:siperional_decompose()获得了意外的关键字参数' ofere'
我正在尝试使用DateTime索引来消化时间序列数据。我将在项目中使用期限,但这给了我一个错误,说没有参数命名时期。我找不到任何东西。但是我看到在StatsModel网站上提到了间隔,有人知道如何克服这种情况吗?
from statsmodels.tsa.seasonal import seasonal_decompose
# Multiplicative Decomposition
decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
decomp_mul.plot()
plt.show()
TypeError Trackback(最近的最新通话) 在 () 2 3#乘法分解 ----> 4 decomp_mul = siensional_decompose(df ['nyemp'],model ='乘法',extrapaly_trend ='freq',ofent = 365) 5 decomp_mul.plot() 6 plt.show()
typeError:simestal_decompose()有一个意外的关键字参数“ ofere”
我使用Google colab
I'm trying to digest time series data with datetime index. I'm going to use period in my project, but it gives me an error saying there is no argument named period. I couldn't find anything for that. But I see that the interval is mentioned on the statsmodel website, does anyone know how I can overcome this situation?
from statsmodels.tsa.seasonal import seasonal_decompose
# Multiplicative Decomposition
decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
decomp_mul.plot()
plt.show()
TypeError Traceback (most recent call last)
in ()
2
3 # Multiplicative Decomposition
----> 4 decomp_mul = seasonal_decompose(df['meantemp'], model='multiplicative', extrapolate_trend='freq', period=365)
5 decomp_mul.plot()
6 plt.show()
TypeError: seasonal_decompose() got an unexpected keyword argument 'period'
i use google colab
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
#prueba conestecódigoque mefuncionóencolab
#freq = 12 es elnúmerode ofercos en unañopara caso
la info la gotuve en el libro Mastering python for Finance de James Ma Weiming(SegundaEdición,Pag 202)
te dejo dice dice dice conelCódigo
季节性分解
分解涉及建模趋势 和季节性,然后将其删除。我们可以使用
statsmodel.tsa.saseanal
模块使用移动平均值来建模非组织时间序列数据集并删除其趋势和季节性组件。通过重复我们的
df_log
在上一节中包含数据集的对数的变量,我们得到以下内容:pensional_decompose() /code>需要一个参数,
freq
,它是一个整数值,指定每个季节周期的周期数。由于我们正在使用每月数据,因此我们预计 在季节性的年份。
该方法返回一个具有三个属性的对象,主要是趋势和季节性成分,以及最终的熊猫系列数据,其趋势和季节性成分已被删除。
有关
statsmodels.t sa.seasonal
模块的更多信息可以找到在这里让我们通过运行以下python code可视化不同的图:
#Prueba con este código que me funcionó en colab
#freq=12 es el número de periodos en un año para este caso
La info la obtuve en el libro Mastering Python for Finance de James Ma Weiming (segunda edición, pag 202)
Te dejo lo que dice junto con el código
Seasonal decomposing
Decomposing involves modeling both the trend and seasonality, and then removing them. We can use the
statsmodel.tsa.seasonal
module to model a nonstationary time series dataset using moving averages and remove its trend and seasonal components.By reusing our
df_log
variable containing the logarithm of our dataset from the previous section, we get the following:The
seasonal_decompose()
method ofstatsmodels.tsa.seasonal
requires a parameter,freq
, which is an integer value specifying the number of periods per seasonal cycle.Since we are using monthly data, we expect 12 periods in a seasonal year.
The method returns an object with three attributes, mainly the trend and seasonal components, as well as the final pandas series data with its trend and seasonal components removed.
More information on the
seasonal_decompose()
method of thestatsmodels.t sa.seasonal
module can be found hereLet's visualize the different plots by running the following Python code:
更新您的问:
我今天检查了一下:注意:STATSMODELS的siensional_decompose()方法的频率参数已被弃用,并用TDS网页中的周期参数替换。
和...
该日期应为DateTime格式,需要使用.set_index(),例如DF.Set_index('date',inplace = true)设置为索引。在您的案例日期为t(根据您的数据集)
Updating your Q:
I checked this today: Note: The frequency parameter of statsmodels’ seasonal_decompose() method has been deprecated and replaced with the period parameter in TDS webpage.
And...
The date should be in datetime format and need to be set as index using .set_index(), e.g., df.set_index('Date', inplace=True). In your case Date is t (as per your dataset)