调查分析中的描述性统计

使用 Python 分析调查数据

EbunOluwa Andrew

Data Scientist

什么是调查分析中的描述性统计?

  • 用于"描述"调查数据的基本度量
  • 描述单个变量及其样本

放大镜与钢笔置于图表上

使用 Python 分析调查数据

为何使用描述性统计?

  • 使数据更易于清晰汇总
  • 形式
    • 表格展示
    • 可视化
  • 有助于识别离群值

带放大镜的多种图表

使用 Python 分析调查数据

频率与分布

  • 按各类别出现次数对数据分组
  • 适用于定性与定量数据
  • 统计原始调查数据的不同结果计数
  • 柱状图、直方图、饼图、折线图等

查看统计数据与图表

使用 Python 分析调查数据

集中趋势:均值、中位数、众数

  • 用单个值表示分布中心
  • 均值=平均值
  • 中位数=升序排列的中间值
  • 众数=出现最频繁的值
使用 Python 分析调查数据

离散程度的度量

  • 判断数据点与中心的离散程度
  • 极差
    • 最大值与最小值之差
  • 标准差
    • 平均方差
    • 反映样本值与均值的平均距离

俯视人群连成上升曲线

使用 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     |

索引: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 分析调查数据

Vamos praticar!

使用 Python 分析调查数据

Preparing Video For Download...