Lecture Notes — Lecture 27: Tables, Cleaning, and Anomalies

Companion to the lecture plan and the worked examples. Read the Definitions before class, the Explanation after it; the practice questions and the lecture quiz close the loop.

Definitions

Explanation

Real tables arrive broken: padded strings, duplicated rows, negative ages, blanks that mean three different things. Cleaning is a specification activity: enumerate what counts as repaired (normalisation), rejected (impossible values), and flagged (possible-but-odd), then apply and LOG. The audit trail is not bureaucracy; it is the difference between cleaning and data destruction - a reader must be able to reconstruct what happened to every row. The hardest decisions are policy, not code: a missing value dropped shortens the series and flattens trends; zero-filled it invents a crash; mean-filled it invents calm. Each choice changes the summary, so the choice ships with the data. Anomalies split into two authority layers: hard rules reject (age -3), statistical flags only nominate (a score 2 sd out) - and clean first, because outliers distort the very statistics used to hunt them.

Examples

The lecture's worked examples live in examples.md; the case studies this lecture builds on are worked in class from the projector. The case sequence with difficulties:

Common misconceptions

Summary and key takeaways

  1. Clean to a written specification: normalise, reject impossibles, flag surprises.
  2. The audit trail ships with the data - silent cleaning is data destruction.
  3. Missing-value policies change summaries; declare the policy beside the result.
  4. Hard rules reject; statistical flags only nominate.
  5. Clean before anomaly-hunting - outliers poison the detectors.

Practice questions

Where this leads

Next lecture: Summaries That Don't Mislead. The quiz below checks this lecture's essentials before we build on them.