課程導論

Python 中的時間序列分析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

時間序列範例:Google Trends

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...