開始使用免費開始

平均值與中位數

現在,你已經學會了怎麼使用 numpy 的函式來更好地理解資料。

棒球資料存放在一個二維 numpy 陣列中,共有 3 欄(身高、體重、年齡)和 1015 列。該 numpy 陣列名為 np_baseball。不過,在重構資料後,你發現有些身高值異常高。那麼,你可以按照指示操作,探索在處理所謂的離群值 (outliers) 時,哪種彙總統計指標更合適。np_baseball 已提前準備好。

本練習屬於課程

Python 入門

檢視課程

練習說明

  • 建立 numpy 陣列 np_height_in,它等於 np_baseball 的第一欄。
  • 印出 np_height_in 的平均值。
  • 印出 np_height_in 的中位數。

動手互動練習

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

import numpy as np

# Create np_height_in from np_baseball


# Print out the mean of np_height_in


# Print out the median of np_height_in
編輯並執行程式碼