参考网上代码 from random import randrangeimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport matplotlib.font_manager as fmfrom statsmodels.graphics.tsaplots import plot_acf ,plot_pacfarr = [38699,37680,36628,35530,34820,34840,35177,35768,36043,36399,36640,36204,34830,33442,31941,30731,29923,28890,27931,26594,25773,24171,22790,21919,21496,20944,20258,19445]def generateData(startDate, endDate): df = pd.DataFrame(arr,columns=['统计年鉴'],index=pd.date_range(startDate, endDate, freq='Y')) return df# 生成测试数据,模拟某商店营业额data = generateData('1992', '2020')print(data)# 绘制时序图myfont = fm.FontProperties(fname=r'C:\Windows\Fonts\STKAITI.ttf')data.plot()plt.legend(prop=myfont) plt.show()# 绘制自相关图plot_acf(data).show()# 绘制偏自相关图plot_pacf(data).show() 总是报错: Traceback (most recent call last): File "F:\mame.py", line 27, in plot_pacf(data).show() File "D:\Software\Python\lib\site-packages\statsmodels\graphics\tsaplots.py", line 307, in plot_pacf acf_x, confint = pacf(x, nlags=nlags, alpha=alpha, method=method) File "D:\Software\Python\lib\site-packages\statsmodels\tsa\stattools.py", line 1033, in pacf raise ValueError(ValueError: Can only compute partial correlations for lags up to 50% of the sample size. The requested nlags 15 must be < 14.>>>
可以参考这篇文章,希望对你有帮助:使用tsfresh报错:Can only compute partial correlation for lugs up to 50% of the sample size._yepeng2007fei的博客-CSDN博客
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632
你好请问这个问题解决了吗?我和你一模一样的问题