ACF时间序列:ValueError:操作数不能与形状一起广播

问题描述 投票:0回答:1

我有一个时间序列对象,该对象具有2列的index和item_count。我正在尝试找到其ACF,但出现错误。

[IN]ts.head()
[OUT]   item_cnt_day
index   
2013-01-01  131479.0
2013-02-01  128090.0
2013-03-01  147142.0
2013-04-01  107190.0
2013-05-01  106970.0

表中有34行。

ts.shape
(34, 1)

import statsmodels.graphics.tsaplots as sgt 

sgt.plot_acf(ts.item_cnt_day, lags = 40, zero=False) #ACF means auto correlation function
#Lags 40 means that we are calculating correlation between a present series and series 40 time periods before.
#zero = false means that you dont calculate correltion between series now and now, because that will alwasy be onebb
plt.title("ACF S&P")
plt.show()


ValueError: operands could not be broadcast together with shapes (39,) (32,) (39,) 
python pandas time-series azure-timeseries-insights
1个回答
0
投票

由于我的系列数据为34行。您的滞后不能超过34。

sgt.plot_acf(ts.item_cnt_day, lags = 33, zero=False) #ACF means auto correlation function

滞后= 33或滞后值低于34不会导致错误

© www.soinside.com 2019 - 2024. All rights reserved.