用 Python 可视化时间序列数据
Thomas Vincent
Head of Data Science, Getty Images
t_1、t_2、t_3、…)与其滞后 3 个时点的值(即 t_4、t_5、t_6、…)之间的相关性
statsmodels是一个 Python 模块,提供用于估计多种统计模型的类与函数,并可进行统计检验和数据探索。
import matplotlib.pyplot as plt
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_acf(co2_levels['co2'], lags=40)
plt.show()

order 3 的偏自相关函数返回序列(t1、t2、t3、…)与自身滞后 3 个时点(t4、t5、t6、…)的相关性,但先去除了 1 阶和 2 阶滞后的全部影响import matplotlib.pyplot as plt
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_pacf(co2_levels['co2'], lags=40)
plt.show()

用 Python 可视化时间序列数据