Lompat ke konten

Pelajaran 26 ยท Projects and Reference

Data Cleaning Glossary and Cheat Sheet

A data cleaning glossary and cheat sheet with key terms, a step-by-step checklist and quick Python, pandas, SQL and spreadsheet snippets for common fixes.

Use this page as a quick reference. The glossary explains the terms used in this tutorial, and the cheat sheet gives short starting points. Every snippet needs rules that fit your data, so read the related lesson before you rely on one.

The checklist

Before

State the question
Protect raw data
Profile
1 / 3

Glossary

Term Meaning
Accuracy How well values match reality
Blocking Limiting record comparisons to those that share a key
Check digit A digit computed from the others to catch typos
Completeness How many required values are present
Consistency Agreement between values that should match
Crosswalk A table that maps IDs between systems
Data dictionary A description of each column and its rules
Entity resolution Deciding which records refer to the same thing
Grain What one row of a table represents
Idempotent Running it again changes nothing further
Imputation Filling missing values with estimates
IQR The range of the middle half of the data
MAD Median absolute deviation, a robust measure of spread
MCAR, MAR, MNAR Three mechanisms that describe why data is missing
Orphan A record whose reference points to nothing
Outlier A value far from most others
Profiling Measuring a dataset before changing it
Quarantine Holding rejected records with reasons
Reconciliation Showing that counts and totals add up
Survivorship Rules for choosing values among duplicates
Tidy data One column per variable, one row per observation, one table per kind of record
Validity Whether values follow format and domain rules

Python cheat sheet

Python Common standard library fixes

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.

pandas cheat sheet

These snippets are read-only. Replace the names with your own.

Task Code
Read as text pd.read_csv(path, dtype=str, keep_default_na=False)
Missing per column df.isna().sum()
Trim text df["c"].str.strip()
To number pd.to_numeric(s, errors="coerce"), then inspect failures
To date pd.to_datetime(s, format="%Y-%m-%d", errors="coerce")
Map categories s.map(mapping), then check for unmapped values
Review duplicates df[df.duplicated(["key"], keep=False)]
Drop duplicates df.drop_duplicates(["key"], keep="last"), after sorting
Flag, then fill df["was_na"] = df["c"].isna(), then fillna
Checked join a.merge(b, on="key", how="left", validate="many_to_one")

See the pandas tutorial for details.

SQL cheat sheet

SQL Common SQL fixes

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

Add a tie-breaker to the ORDER BY whenever two rows can share the same load number. Casting behavior differs between databases, so validate before you convert.

Spreadsheet cheat sheet

Task Formula
Trim spaces =TRIM(A2)
Replace non-breaking spaces =SUBSTITUTE(A2,CHAR(160)," ")
Count a key =COUNTIF(B:B,B2)
Check length =LEN(A2)
Exact lookup =XLOOKUP(A2,Map!A:A,Map!B:B,"UNMAPPED")

Availability and argument separators vary by product, version and locale. See cleaning in spreadsheets for the limits of these formulas.

Which method?

Situation Start with
Small, one-time list A spreadsheet with a raw copy
Data already in a database SQL views and constraints
Complex parsing or matching Python
Recurring files A tested pipeline

Where to go next

Common mistake: copying a cheat sheet snippet without testing it on examples that should fail. A rule that never rejects anything may not be checking anything.

Five questions to ask before you finish

  1. What does one row mean, and is the key unique at that level?
  2. What did you change, and can you show a count for each rule?
  3. What did you remove or reject, and can you get it back?
  4. What did you assume about formats, units, gaps and matches, and who confirmed it?
  5. What is still wrong or uncertain, and does the reader know?

If you cannot answer one of them, you have found your next task.

Habits that prevent most damage

Keep the original. Load identifiers as text. Use explicit formats for numbers and dates. Report unknown values instead of guessing. Count rows before and after joins and removals. Treat unusual values as questions. Protect personal data at every step, including in logs, examples and test files. These habits work in any tool, from a spreadsheet to a large data platform.

Using this page at work

Copy the five questions into your project notes and answer them for each dataset. Over time, add your own entries: markers that your systems use for missing values, date formats by source and the rules that have caught real problems. A short, local cheat sheet that your team keeps current is often more useful than a long general one.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. What does the grain of a table describe?

    Grain shapes keys, duplicates and how to count.
  2. 2. What is survivorship?

    It decides which version of each field represents the entity.
  3. 3. After converting text to numbers with coercion, what should you do?

    Failures are hidden as missing values unless you inspect them.

Summary

  • Prepare, clean, then verify and document.
  • Use precise terms to describe problems.
  • Treat snippets as starting points and test them.
  • Come back whenever you meet a new kind of mess.

Next: Review the whole Data Cleaning course

Progres Anda disimpan di browser ini. Tidak perlu akun.