课题:从原始数据到分析洞察——数据组织全流程实战
一、引言:你还记得多少?
L099 到 L103,我们走完了数据组织与可视化的完整路径:
| 课次 | 主题 | 核心技能 |
|---|---|---|
| L099 | 数据类型与测量尺度 | 区分定性/定量、名义/序数/间隔/比率 |
| L100 | 参数、统计量与抽样分布 | 理解 μ vs x̄、中心极限定理 |
| L101 | 频数分布与列联表 | 构建频数表、理解联合频率 |
| L102 | 数据可视化 | 选择合适的图表类型 |
| L103 | 数据整理与清洗 | 合并、重塑、去重、缺失值处理 |
本课目标: 用一套真实的金融数据集,串联以上所有知识点——从识别数据类型开始,到构建频数分布、选择可视化图表、清洗异常值,最终得出有意义的数据洞察。
二、综合场景:新兴市场 ETF 分析
2.1 场景设定
你是一家基金公司的初级分析师。你的主管给你一份新兴市场 ETF 的数据集,包含 50 只 ETF 的以下字段:
- Ticker:ETF 代码(如 EEM、VWO)
- Category:Morningstar 分类(Diversified Emerging Mkts / China Region / India Equity 等)
- AUM:管理资产规模(百万美元)
- ExpenseRatio:费用率(%)
- 3Y_Return:三年年化回报率(%)
- Morningstar_Rating:晨星评级(1 星到 5 星)
- Inception_Year:成立年份
2.2 数据样本(模拟)
Ticker Category AUM ExpenseRatio 3Y_Return Morningstar_Rating Inception_Year
EEM Diversified Emerging 23500 0.68 4.2 4 2003
VWO Diversified Emerging 82000 0.08 5.1 5 2005
IEMG Diversified Emerging 72500 0.09 4.8 4 2012
FXI China Region 4500 0.74 -2.5 2 2004
MCHI China Region 6200 0.59 -1.8 3 2011
INDA India Equity 8900 0.69 7.2 5 2012
EPI India Equity 2100 0.85 6.5 3 2008
EWZ Brazil Equity 5200 0.63 0.3 3 2000
... ... ... ... ... ... ...
(共 50 条记录)
三、知识点回顾与实战演练
3.1 数据类型与测量尺度(L099)
任务 1:识别每个变量的数据类型和测量尺度
| 变量 | 数据类型 | 测量尺度 | 理由 |
|---|---|---|---|
| Ticker | 定性(Qualitative) | 名义(Nominal) | 标签,无排序意义 |
| Category | 定性 | 名义 | 分类名称,无排序 |
| AUM | 定量(Quantitative) | 比率(Ratio) | 有真实零点,倍数有意义 |
| ExpenseRatio | 定量 | 比率 | 0% 是真实零点 |
| 3Y_Return | 定量 | 间隔(Interval)/比率 | 0% 无真实含义?回报率可正可负,比率尺度 |
| Morningstar_Rating | 定性 | 序数(Ordinal) | 1-5 星有排序,但间距不一定相等 |
| Inception_Year | 定量 | 间隔(Interval) | 年份没有真实零点 |
关键辨析:Morningstar_Rating 为什么是序数而非间隔? - 4 星和 5 星之间的"质量差距"不等于 1 星和 2 星之间的差距 - 你不能说"5 星比 1 星好 5 倍" - 序数数据的运算仅限于 排序和中位数,不适用于均值和标准差
考试常考:
问:晨星评级(1-5 星)最适合用什么集中趋势指标? 答:中位数(Median),因为它是序数数据,不能计算均值。
3.2 参数与统计量(L100)
任务 2:计算 AUM 的样本均值与样本标准差
假设 50 只 ETF 的 AUM 数据如下(单位:百万美元,简化显示):
23500, 82000, 72500, 4500, 6200, 8900, 2100, 5200, ...
样本均值(x̄): $$\bar{x} = \frac{\sum x_i}{n}$$
假设 ∑AUM = 425,000,n = 50 $$\bar{x}_{AUM} = \frac{425,000}{50} = 8,500 \text{ 百万}$$
样本标准差(s): $$s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n-1}}$$
注意:分母是 n-1(自由度减一),这是样本标准差的无偏估计。
核心概念回顾: - 参数(Parameter):描述总体特征的量,如 μ(总体均值)、σ(总体标准差) - 统计量(Statistic):描述样本特征的量,如 x̄(样本均值)、s(样本标准差) - 抽样分布:统计量的概率分布(从同一总体多次抽样得到的分布)
CFA 一级考点:中心极限定理——当 n 足够大(通常 n ≥ 30),样本均值的抽样分布趋近于正态分布 N(μ, σ²/n),无论原始总体分布是什么形状。
3.3 频数分布与列联表(L101)
任务 3:构建 Category 的频数分布表
| Category | 绝对频数 | 相对频率 | 累计频率 |
|---|---|---|---|
| Diversified Emerging Mkts | 15 | 30% | 30% |
| China Region | 10 | 20% | 50% |
| India Equity | 8 | 16% | 66% |
| Brazil Equity | 5 | 10% | 76% |
| Other Emerging | 12 | 24% | 100% |
| 合计 | 50 | 100% |
任务 4:列联表——Category × Morningstar_Rating
| Category | 1-2 星 | 3 星 | 4-5 星 | 合计 |
|---|---|---|---|---|
| Diversified Emerging | 2 | 5 | 8 | 15 |
| China Region | 6 | 3 | 1 | 10 |
| India Equity | 1 | 3 | 4 | 8 |
| Brazil Equity | 3 | 1 | 1 | 5 |
| Other Emerging | 3 | 5 | 4 | 12 |
| 合计 | 15 | 17 | 18 | 50 |
分析发现: - 中国区域 ETF(China Region)中,60%(6/10)评级为 1-2 星——与近期表现一致 - 印度 ETF 中 50%(4/8)为 4-5 星——近年表现优异 - 列联表可以揭示两个分类变量之间的关系模式
考点:联合频率(Joint Frequency)vs 边际频率(Marginal Frequency) - 联合频率:表中每个单元格的值(如 China Region × 1-2 星 = 6) - 边际频率:每行/每列的合计值(如 1-2 星合计 = 15)
3.4 数据可视化(L102)
任务 5:为不同分析目的选择正确的图表
| 分析目的 | 推荐图表 | 理由 |
|---|---|---|
| 比较各 Category 的平均回报率 | 柱状图(Bar Chart) | 分类变量 + 数值变量 |
| 展示 AUM 的分布 | 直方图(Histogram) | 连续变量的频数分布 |
| 关系:ExpenseRatio vs 3Y_Return | 散点图(Scatter Plot) | 两个连续变量的关系 |
| 各 Category 的市场份额(AUM占比) | 饼图(Pie Chart) | 组成部分占整体的比例 |
| ExpenseRatio 的五数概括 | 箱线图(Box Plot) | 显示分布形态 + 异常值 |
| 32 只 ETF 的 AUM 和 ExpenseRatio 对比 | 热力图(Heatmap) | 多变量矩阵 |
可视化黄金法则: 1. 一个图表,一个核心信息——不要在一个图里塞太多 2. Y 轴从零开始——除非你故意要放大差异(柱状图尤其如此) 3. 图例清晰,标签完整——别人不需要翻回来看上下文 4. 避免 3D 效果——扭曲数据感知(饼图不要 3D!)
3.5 数据清洗(L103)
任务 6:识别并处理数据问题
回到我们的 ETF 数据集,假设你发现了以下问题:
问题 A:缺失值
- 3 只 ETF 的 Morningstar_Rating 为空(新基金尚未评级)
- 处理方案: 分析涉及评级的场景使用成对删除;报告评级覆盖率的场景不做删除,标注"NR"
问题 B:异常值
- 一只 ETF 的 AUM 显示为 1,250,000(125 万亿!)
- 经核查,应该是 12,500(多写了一个零)
- 处理方案: 数据更正(修正为 12500)
问题 C:重复值
- VWO 出现两次
- 两条记录完全相同 → 去重(删除一条)
问题 D:格式不一致
- Inception_Year 中有些是四位数年份(2003),有些是完整日期(2003-04-01)
- 处理方案: 标准化——统一提取年份,转为数值型
常见数据问题速查表
| 问题类型 | 识别方法 | 处理方法 |
|---|---|---|
| 缺失值 | count nulls、is.na() | 删除/填补/成对处理 |
| 异常值 | Z-score > 3、四分位距(IQR) | 核实后更正/缩尾/删除 |
| 重复值 | 按 key 字段查重 | 去重 |
| 格式不一致 | 正则匹配、类型检查 | 标准化转换 |
| 类型错误 | 检查每列 dtype | 强制转换 |
| 逻辑矛盾 | AUM > 0,Return 不能低于 -100% | 核实后修正 |
四、综合训练题
选择题
Q1:晨星评级(1-5 星)最适合用哪个集中趋势指标? - A. 算术平均数 - B. 中位数 - C. 几何平均数 - D. 加权平均数
Q2:分析 AUM 和 ExpenseRatio 之间的关系,最合适的图表是? - A. 柱状图 - B. 直方图 - C. 散点图 - D. 饼图
Q3:样本标准差公式的分母是 n-1,这体现了什么? - A. 自由度的损失,使 s 成为 σ 的无偏估计 - B. 数据采集的精度限制 - C. CFA 协会的特殊规定 - D. 样本量越大越需要用 n-1
Q4:以下哪种数据处理操作属于"数据清洗"而非"数据整理"? - A. 将两个数据集按 ticker 合并 - B. 将 CAGR 为 25000% 的值标记为异常 - C. 按 Category 分组求平均回报 - D. 将数据按 AUM 降序排列
Q5:列联表中,单元格 15(Diversified × 4-5星)表示的是? - A. 边际频率 - B. 联合频率 - C. 条件频率 - D. 累计频率
答案
Q1:B — 序数数据的集中趋势应使用中位数,不适用于均值。
Q2:C — 两个连续变量的关系用散点图最合适(可能还会加一条回归线)。
Q3:A — 分母 n-1 是因为我们用一个样本统计量(x̄)替代了总体参数(μ),失去了一个自由度,使得 s² 成为 σ² 的无偏估计。
Q4:B — 异常值检测和处理属于数据清洗(纠正数据错误)。A(合并)、C(聚合)、D(排序)属于数据整理。
Q5:B — 行与列的交集单元格是联合频率。边际频率是行/列合计,条件频率是行内或列内的比例。
五、本模块知识图谱
模块 2.2:组织与可视化数据(L099-L104)
L099 数据类型 ──── 定量 vs 定性、四种尺度
│
L100 参数/统计量 ── μ vs x̄, CLT, 抽样分布
│
L101 频数分布 ──── 频数表、列联表、联合/边际频率
│
L102 数据可视化 ── 柱状图/直方图/散点图/箱线图/饼图
│
L103 数据清洗 ──── 缺失值/异常值/重复/格式不一致
│
L104 综合练习 ◀── 你现在在这里!
六、备考要点
| 优先级 | 考点 | 出现概率 |
|---|---|---|
| ⭐⭐⭐ | 区分名义/序数/间隔/比率尺度 | 极高 |
| ⭐⭐⭐ | 中心极限定理:n≥30,x̄~N(μ, σ²/n) | 极高 |
| ⭐⭐⭐ | 频数分布与列联表中各类频率的计算 | 高 |
| ⭐⭐ | 图表选择:什么数据适合什么图 | 高 |
| ⭐⭐ | 缺失值处理方法的权衡 | 中 |
| ⭐⭐ | 参数 vs 统计量的定义 | 中 |
| ⭐ | 数据整理七大任务(合并/重塑/过滤等) | 低-中 |
下一模块预告: 从 L105 开始,我们将进入 模块 2.3:描述性统计量(Descriptive Statistics)——集中趋势、离散程度、偏度与峰度。这是 CFA 一级量化方法中最重要、考点密度最高的模块之一,准备好计算器!
CFA 一级 · 量化方法 · 模块 2.2 完结 | L104 综合练习 · 2026-07-10
Topic: From Raw Data to Analytical Insight — End-to-End Data Organization
I. Introduction: What Do You Remember?
From L099 to L103, we covered the full data organization and visualization pipeline:
| Lesson | Topic | Core Skill |
|---|---|---|
| L099 | Data Types & Measurement Scales | Distinguishing qualitative vs. quantitative; nominal/ordinal/interval/ratio |
| L100 | Parameters, Statistics & Sampling Distributions | Understanding μ vs. x̄; Central Limit Theorem |
| L101 | Frequency Distributions & Contingency Tables | Building frequency tables; joint frequencies |
| L102 | Data Visualization | Choosing the right chart type |
| L103 | Data Wrangling & Cleaning | Merging, reshaping, deduplication, missing value treatment |
Objective: Using a realistic financial dataset, connect all the above concepts — from identifying data types through building frequency distributions, selecting visualizations, cleaning outliers, and ultimately deriving meaningful insights.
II. Comprehensive Scenario: Emerging Market ETF Analysis
2.1 Scenario Setup
You are a junior analyst at a fund management company. Your supervisor gives you an emerging market ETF dataset containing the following fields for 50 ETFs:
- Ticker: ETF symbol (e.g., EEM, VWO)
- Category: Morningstar Category (Diversified Emerging Mkts / China Region / India Equity, etc.)
- AUM: Assets Under Management (USD millions)
- ExpenseRatio: Expense ratio (%)
- 3Y_Return: 3-year annualized return (%)
- Morningstar_Rating: Morningstar Rating (1 star to 5 stars)
- Inception_Year: Year of inception
2.2 Sample Data (Simulated)
Ticker Category AUM ExpenseRatio 3Y_Return Morningstar_Rating Inception_Year
EEM Diversified Emerging 23500 0.68 4.2 4 2003
VWO Diversified Emerging 82000 0.08 5.1 5 2005
IEMG Diversified Emerging 72500 0.09 4.8 4 2012
FXI China Region 4500 0.74 -2.5 2 2004
MCHI China Region 6200 0.59 -1.8 3 2011
INDA India Equity 8900 0.69 7.2 5 2012
EPI India Equity 2100 0.85 6.5 3 2008
EWZ Brazil Equity 5200 0.63 0.3 3 2000
... ... ... ... ... ... ...
(50 records total)
III. Knowledge Review & Hands-On Practice
3.1 Data Types & Measurement Scales (L099)
Task 1: Identify the data type and measurement scale for each variable
| Variable | Data Type | Measurement Scale | Rationale |
|---|---|---|---|
| Ticker | Qualitative | Nominal | Label; no ranking meaning |
| Category | Qualitative | Nominal | Category name; no ordering |
| AUM | Quantitative | Ratio | True zero exists; multiples are meaningful |
| ExpenseRatio | Quantitative | Ratio | 0% is a true zero |
| 3Y_Return | Quantitative | Ratio | Returns can be negative, but zero has meaning; ratios like "double" are valid |
| Morningstar_Rating | Qualitative | Ordinal | 1-5 stars have order, but intervals are not equal |
| Inception_Year | Quantitative | Interval | Years have no true zero |
Key Distinction: Why is Morningstar_Rating ordinal rather than interval? - The "quality gap" between 4 stars and 5 stars is not equal to the gap between 1 star and 2 stars - You cannot say "5 stars is 5 times better than 1 star" - Operations on ordinal data are limited to ranking and median; mean and standard deviation are inappropriate
Exam Favorite:
Q: Which measure of central tendency is most appropriate for Morningstar Ratings (1-5 stars)? A: Median, because this is ordinal data — the mean is not meaningful.
3.2 Parameters & Statistics (L100)
Task 2: Calculate the sample mean and sample standard deviation of AUM
Assuming AUM data for 50 ETFs (USD millions, simplified):
23500, 82000, 72500, 4500, 6200, 8900, 2100, 5200, ...
Sample Mean (x̄): $$\bar{x} = \frac{\sum x_i}{n}$$
Assuming ∑AUM = 425,000, n = 50: $$\bar{x}_{AUM} = \frac{425,000}{50} = 8,500 \text{ million}$$
Sample Standard Deviation (s): $$s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n-1}}$$
Note: The denominator is n-1 (degrees of freedom adjustment) — this makes s an unbiased estimator of σ.
Core Concept Review: - Parameter: A quantity describing a population, e.g., μ (population mean), σ (population standard deviation) - Statistic: A quantity describing a sample, e.g., x̄ (sample mean), s (sample standard deviation) - Sampling Distribution: The probability distribution of a statistic (derived from repeated sampling from the same population)
CFA Level 1 Key Point: Central Limit Theorem — When n is sufficiently large (typically n ≥ 30), the sampling distribution of the sample mean approaches a normal distribution N(μ, σ²/n), regardless of the shape of the original population distribution.
3.3 Frequency Distributions & Contingency Tables (L101)
Task 3: Build a frequency distribution table for Category
| Category | Absolute Frequency | Relative Frequency | Cumulative Frequency |
|---|---|---|---|
| Diversified Emerging Mkts | 15 | 30% | 30% |
| China Region | 10 | 20% | 50% |
| India Equity | 8 | 16% | 66% |
| Brazil Equity | 5 | 10% | 76% |
| Other Emerging | 12 | 24% | 100% |
| Total | 50 | 100% |
Task 4: Contingency Table — Category × Morningstar_Rating
| Category | 1-2 Stars | 3 Stars | 4-5 Stars | Total |
|---|---|---|---|---|
| Diversified Emerging | 2 | 5 | 8 | 15 |
| China Region | 6 | 3 | 1 | 10 |
| India Equity | 1 | 3 | 4 | 8 |
| Brazil Equity | 3 | 1 | 1 | 5 |
| Other Emerging | 3 | 5 | 4 | 12 |
| Total | 15 | 17 | 18 | 50 |
Analytical Findings: - 60% (6/10) of China Region ETFs are rated 1-2 stars — consistent with recent underperformance - 50% (4/8) of India Equity ETFs are rated 4-5 stars — reflecting strong recent returns - Contingency tables reveal relationship patterns between two categorical variables
Exam Focus: Joint Frequency vs. Marginal Frequency - Joint Frequency: Each cell value (e.g., China Region × 1-2 Stars = 6) - Marginal Frequency: Row/column totals (e.g., 1-2 Stars total = 15)
3.4 Data Visualization (L102)
Task 5: Select the correct chart for each analytical purpose
| Analytical Purpose | Recommended Chart | Rationale |
|---|---|---|
| Compare average returns across Categories | Bar Chart | Categorical × numerical |
| Show the distribution of AUM | Histogram | Continuous variable frequency distribution |
| Relationship: ExpenseRatio vs. 3Y_Return | Scatter Plot | Two continuous variables |
| Market share of each Category (AUM %) | Pie Chart | Parts of a whole |
| Five-number summary of ExpenseRatio | Box Plot | Distribution shape + outliers |
| AUM and ExpenseRatio comparison across ETFs | Heatmap | Multivariate matrix |
Golden Rules of Visualization: 1. One chart, one core message — Don't overcrowd a single chart 2. Y-axis should start at zero — Unless you deliberately want to exaggerate differences (especially true for bar charts) 3. Clear legends, complete labels — The reader should not need to look back at context 4. Avoid 3D effects — They distort data perception (never use 3D pie charts!)
3.5 Data Cleaning (L103)
Task 6: Identify and handle data problems
Returning to our ETF dataset, suppose you discover the following issues:
Problem A: Missing Values
- 3 ETFs have no Morningstar_Rating (new funds, not yet rated)
- Solution: Use pairwise deletion for analyses involving ratings; for coverage reporting, label as "NR" without deletion
Problem B: Outliers
- One ETF shows AUM of 1,250,000 (125 trillion!)
- After verification: should be 12,500 (an extra zero)
- Solution: Data correction (correct to 12,500)
Problem C: Duplicates
- VWO appears twice
- Both records are identical → Deduplicate (delete one)
Problem D: Inconsistent Formats
- Some Inception_Year entries are 4-digit years (2003), others are full dates (2003-04-01)
- Solution: Standardize — Extract year uniformly, convert to numeric
Common Data Problems Quick Reference
| Problem Type | Detection Method | Treatment |
|---|---|---|
| Missing Values | Count nulls, is.na() | Deletion / Imputation / Pairwise |
| Outliers | Z-score > 3, IQR method | Verify & correct / Winsorize / Delete |
| Duplicates | Check duplicates by key fields | Deduplicate |
| Format Inconsistency | Regex matching, type checking | Standardize & convert |
| Wrong Data Type | Inspect column dtypes | Cast/convert |
| Logical Contradiction | AUM > 0, Return cannot be < -100% | Verify & correct |
IV. Comprehensive Practice Questions
Multiple Choice
Q1: Which measure of central tendency is most appropriate for Morningstar Ratings (1-5 stars)? - A. Arithmetic mean - B. Median - C. Geometric mean - D. Weighted mean
Q2: To analyze the relationship between AUM and ExpenseRatio, the most appropriate chart is a: - A. Bar chart - B. Histogram - C. Scatter plot - D. Pie chart
Q3: The denominator in the sample standard deviation formula is n-1. This reflects: - A. Loss of one degree of freedom, making s an unbiased estimator of σ - B. Precision limitations in data collection - C. A special rule by CFA Institute - D. The larger the sample, the more n-1 is needed
Q4: Which of the following operations is "data cleaning" rather than "data wrangling"? - A. Merging two datasets by ticker - B. Flagging a CAGR of 25,000% as an outlier - C. Grouping by Category to calculate average return - D. Sorting data by AUM in descending order
Q5: In a contingency table, the cell showing 15 (Diversified × 4-5 Stars) represents a: - A. Marginal frequency - B. Joint frequency - C. Conditional frequency - D. Cumulative frequency
Answers
Q1: B — For ordinal data, the median is the appropriate measure of central tendency. The mean is not meaningful.
Q2: C — A scatter plot is ideal for examining the relationship between two continuous variables (possibly adding a regression line).
Q3: A — The denominator n-1 accounts for using x̄ (a sample statistic) in place of μ (population parameter), losing one degree of freedom. This makes s² an unbiased estimator of σ².
Q4: B — Outlier detection and handling is data cleaning (correcting data errors). A (merging), C (aggregation), and D (sorting) are data wrangling operations.
Q5: B — A cell at the intersection of a row and column is a joint frequency. Marginal frequencies are row/column totals; conditional frequencies are proportions within a row or column.
V. Module Knowledge Map
Module 2.2: Organizing & Visualizing Data (L099-L104)
L099 Data Types ──── Quantitative vs. Qualitative, Four Scales
│
L100 Parameters/Stats ── μ vs. x̄, CLT, Sampling Distributions
│
L101 Frequency Distributions ── Tables, Contingency Tables, Joint/Marginal Freq
│
L102 Data Visualization ── Bar/Histogram/Scatter/Box/Pie Charts
│
L103 Data Cleaning ── Missing Values/Outliers/Duplicates/Format Issues
│
L104 Comprehensive Practice ◀── You are here!
VI. Exam Priorities
| Priority | Topic | Likelihood |
|---|---|---|
| ⭐⭐⭐ | Distinguishing nominal/ordinal/interval/ratio scales | Very High |
| ⭐⭐⭐ | Central Limit Theorem: n≥30, x̄~N(μ, σ²/n) | Very High |
| ⭐⭐⭐ | Calculating frequencies in distributions and contingency tables | High |
| ⭐⭐ | Chart selection: which data suits which chart | High |
| ⭐⭐ | Trade-offs in missing value treatment methods | Medium |
| ⭐⭐ | Parameter vs. Statistic definitions | Medium |
| ⭐ | Seven data wrangling tasks (merge/reshape/filter, etc.) | Low-Medium |
Next Module Preview: Starting from L105, we enter Module 2.3: Descriptive Statistics — measures of central tendency, dispersion, skewness, and kurtosis. This is one of the most important and highest-density modules in CFA Level 1 Quantitative Methods. Get your calculator ready!
CFA Level 1 · Quantitative Methods · Module 2.2 Complete | L104 Comprehensive Practice · 2026-07-10