用描述統計摘要你的資料

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

Stefan Jansen

Instructor

掌握你的資料

  • 目標:抓住關鍵量化特性
  • 重要面向:
    • 集中趨勢:哪些值是「典型」?
    • 離散程度:有離群值嗎?
    • 各變數的整體分佈
在 Python 中匯入與管理財務資料

集中趨勢

  • 平均數(mean):$\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • 中位數:50% 的值更小/更大
  • 眾數:最常出現的值

對稱分佈

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

集中趨勢

  • 平均數(mean):$\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • 中位數:50% 的值更小/更大
  • 眾數:最常出現的值

偏態分佈

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

集中趨勢

  • 平均數(mean):$\displaystyle \bar{x} = \frac{1}{n}\sum_{i=1}^n x_i$
  • 中位數:50% 的值更小/更大
  • 眾數:最常出現的值

雙峰分佈

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

計算摘要統計量

nasdaq = pd.read_excel('listings.xlsx', sheet_name='nasdaq', na_values='n/a')
market_cap = nasdaq['Market Capitalization'].div(10**6)
market_cap.mean()
3180.7126214953805
market_cap.median()
225.9684285
market_cap.mode()
0.0
在 Python 中匯入與管理財務資料

計算摘要統計量

marketcaphist.png

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

離散程度

  • 變異數:將各值與平均數之差平方後相加,再除以 $n-1$
    • $\displaystyle var = \frac{1}{n-1}\sum_{i=1}^n(x_i-\bar{x})^2$
  • 標準差:變異數的平方根
    • $\displaystyle sd = \sqrt{var}$

marketcapvar.png

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

計算變異數與標準差

variance = market_cap.var()
print(variance)
648773812.8182
np.sqrt(variance)
25471.0387
market_cap.std()
25471.0387
在 Python 中匯入與管理財務資料

一起來練習吧!

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

Preparing Video For Download...