開始使用免費開始

繪製資料集中所有時間序列

jobs DataFrame 含有 16 條時間序列,代表 2001 到 2010 年各產業的失業率。一次要視覺化這麼多時間序列看起來不少,不過第 4 章已經介紹過分面圖。這個練習中,你會探索 jobs DataFrame 中的部分時間序列,並從這些圖中擷取有意義的資訊。

本練習屬於課程

使用 Python 視覺化時間序列資料

檢視課程

練習說明

  • 檢視 jobs_subset 的前 5 列。
  • 以 2 列 2 欄的版面配置,為新的 jobs_subset DataFrame 建立分面圖。並確保各子圖之間不共用 x 軸與 y 軸。

動手互動練習

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

# A subset of the jobs DataFrame
jobs_subset = jobs[['Finance', 'Information', 'Manufacturing', 'Construction']]

# Print the first 5 rows of jobs_subset
print(____)

# Create a facetted graph with 2 rows and 2 columns
ax = ____(subplots=____,
                      layout=____,
                      sharex=____,
                      sharey=____,
                      linewidth=0.7,
                      fontsize=3,
                      legend=False)

plt.show()
編輯並執行程式碼