開始使用免費開始

中國、印度與美國的通膨走勢

最後,seaborn 套件提供了用來視覺化類別變數各層級分布的函式。

在接下來的兩個練習中,你會使用來自 FRED 的資料,檢視過去 50 多年中國、印度與美國的歷史通膨資料。在開始使用你剛學到的函式之前,先熟悉原始資料會更好。pandaspdmatplotlib.pyplotpltseabornsns 已經為你匯入。FRED 的通膨資料已放在你的工作空間中,名稱為 inflation

本練習屬於課程

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

檢視課程

練習說明

  • 使用 .info() 檢視 inflation
  • 'Country'inflation 分組,並指定給 inflation_by_country
  • 在 for 迴圈中,逐一取出 inflation_by_country 回傳的 countrydata 組合。每次迭代時,對 data 呼叫 .plot(),並將 title 設為 country,以顯示歷史時間序列。

動手互動練習

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

# Inspect the inflation data
inflation.____()

# Create inflation_by_country
inflation_by_country = inflation.____(____)

# Iterate over inflation_by_country and plot the inflation time series per country
for country, data in inflation_by_country:
    # Plot the data
    data.____(____=____)
    # Show the plot
    plt.show()
編輯並執行程式碼