彙整時間序列資料中的數值

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

Thomas Vincent

Head of Data Science, Getty Images

取得資料的數值摘要

  • 這組資料的平均值是多少?
  • 這個時間序列觀測到的最大值是什麼?
使用 Python 視覺化時間序列資料

.describe() 會自動計算 DataFrame 中所有數值欄的關鍵統計量。

print(df.describe())
               co2
count  2284.000000
mean    339.657750
std      17.100899
min     313.000000
25%     323.975000
50%     337.700000
75%     354.500000
max     373.900000
使用 Python 視覺化時間序列資料

用盒鬚圖彙整資料

ax1 = df.boxplot()
ax1.set_xlabel('Your first boxplot')
ax1.set_ylabel('Values of your data')
ax1.set_title('Boxplot values of your data')

plt.show()
使用 Python 視覺化時間序列資料

CO2 資料的數值盒鬚圖

你的時間序列的盒鬚圖

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

用長條圖彙整資料

ax2 = df.plot(kind='hist', bins=100)
ax2.set_xlabel('Your first histogram')
ax2.set_ylabel('Frequency of values in your data')
ax2.set_title('Histogram of your data with 100 bins')

plt.show()
使用 Python 視覺化時間序列資料

CO2 資料的數值長條圖

100 個區間的長條圖

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

用密度圖彙整資料

ax3 = df.plot(kind='density', linewidth=2)
ax3.set_xlabel('Your first density plot')
ax3.set_ylabel('Density values of your data')
ax3.set_title('Density plot of your data')

plt.show()
使用 Python 視覺化時間序列資料

CO2 資料的數值密度圖

你的資料的密度圖

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

一起來練習吧!

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

Preparing Video For Download...