ValueError: Can only compute partial correlations for lags up to 50% of the sample size. The request

在这里插入图片描述

在这里插入图片描述
注意看报错,说lags要小于5,因此设置lags=4

在这里插入图片描述

import pymysql import time,os import re import requests import urllib from datetime import datetime from statsmodels.graphics.tsaplots import plot_acf, plot_pacf # ---------连接-------------- connect = pymysql.connect(host='localhost', # 本地数据库 user='root', password='123456', port=3306, charset='utf8') #服务器名,账户,密码,数据库名称 cur = connect.cursor() print(cur) # 读取数据 try: select_sqli = "SELECT time,xiaoliang FROM sheji.sale where chexing='海豚';" cur.execute(select_sqli) data = pd.DataFrame(cur.fetchall(), columns=['time', 'xiaoliang']) except Exception as e: print("读取数据失败:", e) else: print("读取数据成功") # 转换时间格式 data['time'] = pd.to_datetime(data['time'], format='%Y-%m') data['xiaoliang'] = data['xiaoliang'].astype(int) data = data.set_index('time') diff_data = data.diff().dropna() plot_acf(diff_data) plot_pacf(diff_data)报错Warning (from warnings module): File "C:\Users\86186\AppData\Local\Programs\Python\Python38\lib\site-packages\statsmodels\graphics\tsaplots.py", line 348 warnings.warn( FutureWarning: The default method 'yw' can produce PACF values outside of the [-1,1] interval. After 0.13, the default will change tounadjusted Yule-Walker ('ywm'). You can use this method now by setting method='ywm'. Traceback (most recent call last): File "C:/Users/86186/Desktop/arima.py", line 39, in <module> plot_pacf(diff_data) File "C:\Users\86186\AppData\Local\Programs\Python\Python38\lib\site-packages\statsmodels\graphics\tsaplots.py", line 363, in plot_pacf acf_x, confint = pacf(x, nlags=nlags, alpha=alpha, method=method) File "C:\Users\86186\AppData\Local\Programs\Python\Python38\lib\site-packages\statsmodels\tsa\stattools.py", line 996, in pacf raise ValueError( ValueError: Can only compute partial correlations for lags up to 50% of the sample size. The requested nlags 14 must be < 10.
05-31
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

茶冻茶茶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值