跳到正文

第 26 课 · Projects and Reference

EDA Glossary and Cheat Sheet

A quick reference for exploratory data analysis: a step-by-step checklist, which summaries and charts to use, common pandas and SQL calls and key terms.

Keep this page open while you work. It collects the routine, the choices and the vocabulary from the whole tutorial. Use it as a prompt for thinking, not as a script to follow blindly.

The EDA checklist

Before and first

Question Decision, metric, period
Source Origin and filters
First look Size, types, grain, keys
1 / 3

Which summary and chart?

Data Summaries Charts
One numeric n, missing, median, quartiles, mean, spread Histogram, ECDF, box plot
One category counts, shares, distinct values Sorted bars
Two numeric Pearson, Spearman, binned medians Scatter, hexbin
Category and numeric per-group n, center, spread Box or strip plots
Two categories crosstab, row shares Grouped bars, heatmap
Many numeric correlation matrix Heatmap, pair plot
Over time totals or levels per period, changes Line chart, cohort table

pandas quick reference

These lines assume a DataFrame called df with the named columns.

Python
df.shape                               # (rows, columns)
df.dtypes                              # type of each column
df.head(); df.tail(); df.sample(5, random_state=1)
df.info()                              # non-missing counts and memory
df.describe(include="all")             # overview of columns
df.isna().mean().sort_values()         # missing share per column
df.duplicated(subset=["id"]).sum()     # repeated keys after the first
df["c"].value_counts(dropna=False)     # frequencies with missing
df.groupby("g")["x"].agg(["count", "median", "mean"])
pd.crosstab(df["a"], df["b"], normalize="index")
df.corr(numeric_only=True)             # Pearson by default
pd.cut(df["x"], bins=[0, 10, 100])     # chosen edges
pd.qcut(df["x"], 4)                    # quartile bins
df.set_index("date").resample("W")["x"].sum()
df.merge(other, on="k", validate="many_to_one")

SQL profiling query

SQL A reusable profiling query

Press Run (or Ctrl + Enter) to see the result here.

COUNT(column) skips NULL, and so do AVG, MIN and MAX. See GROUP BY for per-group versions.

A standard-library profiler

Python Profile any list of dictionaries

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This helper expects at least one row, and every row must have the same keys. It treats only None and empty text as missing, so add your own markers.

Glossary

Term Meaning
Anomaly Something that does not fit the expected pattern
Base rate How common something is to begin with
Bimodal Having two peaks
Bootstrap Resampling with replacement to study variation
Cardinality Number of distinct values
Cohort Group that shares a starting event in a period
Confounder Third variable that influences both cause and outcome
Collider Variable influenced by two others; selecting on it can bias
Contingency table Counts of combinations of categories
Correlation A measure of association, such as linear or rank-based
Data dictionary Description of columns, units and meanings
ECDF Share of values at or below each point
EDA Exploring data to understand it and to find problems and ideas
Effect size How large a difference or association is
Grain What one row represents
IQR Q3 minus Q1
Leakage Using information that is unavailable at decision time
MAD In this tutorial, the median absolute deviation from the median
Median Middle value after sorting
Missing not at random Missingness that depends on unseen values
Outlier Value far from most others
Quantile Cut point in sorted data
Reconciliation Matching results with independent totals
Regression to the mean Extreme results tending to be followed by less extreme ones
Resampling (time) Changing the time interval of a series
Selection bias Data differing systematically from the target population
Simpson's paradox A subgroup pattern that reverses when groups are combined
Skew Asymmetry with a longer tail on one side
Stratification Comparing within layers of another variable
Survivorship bias Seeing only the cases that remained

Ten habits to keep

  1. Write the question before the code.
  2. State the grain and test the key.
  3. Report n and missing counts.
  4. Plot before you rely on a single number.
  5. Compare like with like.
  6. Investigate unusual values before changing them.
  7. Reconcile totals after every join and filter.
  8. Say "associated with" unless your study design supports cause.
  9. Record decisions and keep raw data unchanged.
  10. Protect personal and confidential data.

A checklist cannot know what your data means. Domain experts and data owners remain your best source of context.

Where to go next

Strengthen your tools with pandas, Matplotlib and SQL. Learn formal inference in statistics and probability. Then practice on a public dataset that you are allowed to use: ask a question, follow the checklist and write a one-page report.

How to use this page

Use the table to choose a starting view, not a final one. After the first chart or summary, ask what it hides. A box plot can hide two peaks, a correlation can hide a curve, an overall rate can hide different groups and a monthly total can hide missing days. Then pick a second view that would expose that weakness.

When you finish, check that your notes answer four questions: What is one row? What did you exclude and why? Which findings did you verify in a second way? What would change your conclusion?

When you are stuck

Return to single rows. Pick one surprising number, list the records behind it and read them. Trace one record from the raw file through every filter and join. This often reveals a definition you misunderstood or a step that behaves differently from what you intended. If the records look right, ask someone who knows the process to read them with you.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Which chart is a good first view of one numeric variable?

    A histogram shows the shape of a numeric distribution.
  2. 2. What does COUNT(column) do with NULL values in SQL?

    COUNT(*) counts rows, while COUNT(column) counts non-null values.
  3. 3. What is the grain of a table?

    Knowing the grain protects counts and sums.

Summary

  • Follow the routine: question, source, first look, explore, check and report.
  • Choose summaries and charts based on variable types.
  • Keep the pandas and SQL profiling snippets close.
  • Use shared vocabulary precisely.
  • Let context and careful checks guide every conclusion.

Next: Back to the Exploratory Data Analysis tutorial

你的学习进度保存在此浏览器中,无需账号。