课程简介

Python 中的时间序列分析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

时间序列示例:Google 趋势

Python 中的时间序列分析

时间序列示例:气候数据

Python 中的时间序列分析

时间序列示例:季度收益数据

Python 中的时间序列分析

多序列示例:天然气与取暖油

Python 中的时间序列分析

课程目标

  • 学习时间序列模型
  • 将数据拟合到时间序列模型
  • 用模型预测未来
  • 学习在 Python 中使用相关统计包
  • 给出这些模型的具体应用示例
Python 中的时间序列分析

一些实用的 Pandas 工具

  • 将索引转换为 datetime
      df.index = pd.to_datetime(df.index)
    
  • 绘制数据
      df.plot()
    
  • 切片数据
      df['2012']
    
Python 中的时间序列分析

一些实用的 Pandas 工具

  • 合并两个 DataFrame
      df1.join(df2)
    
  • 重采样数据(如日频到周频)
      df = df.resample(rule='W').last()
    
Python 中的时间序列分析

更多 pandas 函数

  • 计算时间序列的涨跌幅与差分
      df['col'].pct_change()
      df['col'].diff()
    
  • Series 的 pandas 相关系数方法
      df['ABC'].corr(df['XYZ'])
    
  • pandas 自相关
      df['ABC'].autocorr()
    
Python 中的时间序列分析

让我们练习吧!

Python 中的时间序列分析

Preparing Video For Download...