開始使用免費開始

視覺化長期的原油價格趨勢

在前一支影片中,你學會如何從 Federal Reserve Economic Data(FRED) 入口擷取資料。

在這裡,你會使用這個新的資料來源,將近 50 年的原油價格趨勢視覺化,特別是西德州中級原油(WTI)的即期原油價格。DataReaderdatepandas 作為 pd,以及 matplotlib.pyplot 作為 plt 都已經匯入。

本練習屬於課程

在 Python 中匯入與管理財務資料

檢視課程

練習說明

  • 使用 date()start 設為 1968 年 1 月 1 日,並把 series 設為系列代碼 'WTISPLC'
  • series 作為資料、'fred' 作為資料來源,以及 start 作為開始日期傳入 DataReader()。指定給 oil_price
  • 使用 .info() 檢視 oil_price
  • 以標題 "Oil Price" 繪製並顯示 oil_price 序列。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Set start date
start = ____

# Set series code
series = 'WTISPLC'

# Import the data
oil_price = DataReader(____, ____, start=____)

# Inspect the price of oil
oil_price.info()

# Plot the price of oil
____

# Show the plot
plt.show()
編輯並執行程式碼