数据源 原始数据源 import matplotlib.pyplot as plt from statsmodels.graphics.tsaplots import plot_acf from statsmodels.graphics.tsaplots import plot_pacf # 原始时间序列图 plt.figure(figsize=(9,3),dpi=100) plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 df1['收入'].plot(color='green', marker='o', linestyle='dashed', linewidth=1, markersize=2) plt.ylabel('收入') plt.title("收入时间序列分析图") 确定数据是与时间是否存在强相关性的 # 自相关系数,查看数据与时间的相关性 plot_acf(df1['收入']) plt.title("原始序列的自相关(ACF)图") plt.show() # 绘制偏自相关函数(PACF)图 plt.figure(figsize=(12, 6)) plot_pacf(df1['收入'], lags=13, title='偏自相关函数(PACF)图') plt.show()