ACF Time series: ValueError: operands could not be broadcast together with shapes

ACF Time series: ValueError: operands could not be broadcast together with shapes

我有一个时间序列对象,它有 2 列索引和 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

table 语句中有 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,) 

因为我的系列数据是34行。您的延迟不能超过 34。

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

lags=33 或任何低于 34 的滞后值都不会导致错误