問卷分析中的描述統計

使用 Python 分析問卷資料

EbunOluwa Andrew

Data Scientist

什麼是描述統計?

  • 用於「描述」問卷資料的基本量測。
  • 包含單一變數與相關樣本的描述。

放大鏡與筆覆蓋在圖表上

使用 Python 分析問卷資料

為何要用描述統計?

  • 讓資料清楚摘要化
  • 形式
    • 表格式呈現
    • 視覺化
  • 協助辨識離群值

放大檢視的各式圖表

使用 Python 分析問卷資料

次數與分配

  • 依各組出現次數彙整資料
  • 適用於質性與量化資料
  • 原始問卷資料中不同結果的計數
  • 長條圖、直方圖、圓餅圖、折線圖等

檢視統計資料、圖形與圖表

使用 Python 分析問卷資料

集中趨勢:mean、median、mode

  • 反映分配中心的單一數值
  • Mean = 平均值
  • Median = 由小到大排序後的中位數
  • Mode = 出現最頻繁的值
使用 Python 分析問卷資料

變異量測

  • 判斷資料點距離中心有多分散
  • Range
    • 最大與最小值之差
  • Standard deviation
    • 平均離差
    • 說明資料值與平均數的距離

由上往下看的人群連成的成長曲線圖

使用 Python 分析問卷資料

問卷:dietary_habits

dietary_habits.head()
| Age   | Gender | meals_per_day | eat_out_per_wk |
|-------|--------|---------------|----------------|
| 18-24 | Male   |             5 |              4 |
| 18-24 | Male   |             4 |              1 |
| 45-54 | Male   |             3 |              3 |
| 18-24 | Male   |             2 |              1 |
| 18-24 | Female |             3 |              1 |
使用 Python 分析問卷資料

次數分配:dietary_habits

dietary_habits.Gender.value_counts().to_frame("Number")
|        | Number |
|--------|--------|
| Male   | 40     |
| Female | 38     |

Index: Gender

使用 Python 分析問卷資料

次數分配:dietary_habits

dietary_habits.Gender.value_counts().to_frame("Number").plot(kind='bar')

性別次數分配長條圖

使用 Python 分析問卷資料

集中趨勢量測:dietary_habits

  • .mean()
  • .median()
  • .mode()
使用 Python 分析問卷資料

集中趨勢量測:dietary_habits

  • .mean()
dietary_habits.mean()
| meals_per_day  | 3.128205 |
| eat_out_per_wk | 1.897436 |
| dtype: float64 |          |
使用 Python 分析問卷資料

集中趨勢量測:dietary_habits

  • .median()
dietary_habits.median()
| meals_per_day  | 3.0 |
| eat_out_per_wk | 1.5 |
| dtype: float64 |     |
使用 Python 分析問卷資料

集中趨勢量測:dietary_habits

  • .mode()
dietary_habits.mode()
| Age   | Gender | meals_per_day | eat_out_per_wk |
|-------|--------|---------------|----------------|
| 18-24 | Male   |             3 |              1 |
使用 Python 分析問卷資料

變異量測:dietary_habits

print(dietary_habits.meals_per_day.max() - dietary_habits.meals_per_day.min())
3
print(dietary_habits.meals_per_day.std())
0.6518500018473766
使用 Python 分析問卷資料

一起來練習吧!

使用 Python 分析問卷資料

Preparing Video For Download...