1. Home
  2. Explore
  3. Computer Science
  4. Data Cleaning Framework

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Data Cleaning Framework

Data Cleaning: The CLEAN Framework

Data cleaning is not about achieving perfection—it is about making the data good enough to analyze, share, and iterate on. Think of it like peeling an onion: first layer removes obvious dirt, second polishes and standardizes, third refines after initial analysis.

This framework is designed for aspiring data analysts working on portfolio projects and mirrors real-world practices used by data directors and lead analysts. The process relies on a five-step acronym: CLEAN.


Conceptualize the Data

Before any cleaning begins, a thoughtful analyst steps back to understand what the dataset actually represents. This step answers three foundational questions:

  • What is the grain of the table? (What does each row represent?)

  • What are the key metrics? (Numeric measures of interest)

  • What are the key dimensions? (Categorical attributes for slicing)

Example: GameZone Dataset

  • Each row = one unique order (identified by Order ID)

  • Key metric = USD price

  • Key dimensions = time (purchase/ship date), product name, purchase platform, marketing channel, account creation method, country code

  • Sample story: User TC0 placed an order on Dec 24, 2020; shipped two days later; bought a Nintendo Switch for ~$170 via the website; came through affiliate marketing; account creation method unknown; located in the United States.

Best practice: If a stakeholder wants to understand sales trends across regions, the analyst knows to prioritize USD price and geographic dimensions.


Locate Solvable Issues

These are problems the analyst can fix independently—no need to consult a stakeholder for business context. Common categories:

  • Inconsistent data formats (e.g., dates in multiple formats)

  • Inconsistent spellings or categorizations (e.g., product names spelled differently)

  • Nulls (sometimes solvable when a default value is known, e.g., "Unknown")

  • Duplicates

First-Pass Cleaning Workflow

  1. Eye-ball the data for glaring issues.

  2. Use filters to check distinct values for every column.

  3. Document issues in an issues log.

Example Issues Found in GameZone

Issue

Solvable?

Action

Purchase timestamp in inconsistent date formats

Yes

Reformat using date functions

Missing dates (null)

No (cannot infer)

Leave; only 1 record

Inconsistent product name spelling (e.g., "27 inches 4K Gaming Monitor" vs another variant)

Yes

Standardize using IF statement (like a CASE WHEN in SQL)

USD price missing or $0 transactions

No (no reference table)

Flag and document

Missing marketing channel and account creation method

Yes

Replace blanks with "Unknown"

Missing country code

No (cannot infer)

Document

Nonsensical values in regional lookup table

Yes (source of truth exists)

Look up correct region

Best Practices

  • Create a new tab replicating the original data (never overwrite).

  • Add a new column named _cleaned to the right of the original (e.g., purchase_timestamp_cleaned).

  • Use pivot tables to detect duplicates. For GameZone, ~145 duplicates out of 20k records (0.7%)—too small to affect analysis, so leave them and document.

Important: Only delete duplicates after obtaining full business context confirming they are genuine duplicates.


Evaluate Unsolvable Issues

These are problems that cannot be resolved without additional business context or technical investigation. Categories:

  • Missing data where the value cannot be inferred

  • Outliers or anomalous values that may or may not represent real events

  • Business logic violations (e.g., ship date before purchase date)

Handling on the Job vs. in Portfolio Projects

  • On the job: consult stakeholders or engineering teams.

  • In portfolio projects: document the magnitude and surface the issue in the write-up.

Example: Negative Time to Ship

A logic check reveals ~2,000 records (≈10%) where ship_timestamp is before purchase_timestamp. The analyst cannot fix this with the data on hand, but:

  • The ship timestamp is not a key dimension for the main analysis (sales trends by region). The impact is minimal.

  • If a stakeholder later asked about time to ship, this column would require deeper investigation.

  • Do not delete 10% of the dataset; leave the records and note the issue.

When to Impute

Imputation is rarely used by data analysts because it risks introducing bias. Acceptable only under these conditions:

  • A reliable source of truth exists (e.g., a look-up table).

  • Clear business logic gives confidence in the inferred value.

  • Data completeness is prioritized over data accuracy (rare for analysts).

For outliers, a quick sanity check (sort descending/ascending) suffices; deeper outlier detection happens during exploratory analysis.

Rule of thumb: If less than 20% of records in a column are problematic, document and move on. If more than 70% are corrupted, the column is likely unusable.


Augment the Data

Enhance the dataset to make it more flexible and robust for analysis. This step involves adding:

  • Time grains – slice purchase timestamps by week, month, year.

  • Calculated metrics – e.g., time_to_ship = ship_timestamp - purchase_timestamp (in days).

  • External dimensions – bring in region from a clean lookup table (e.g., using VLOOKUP in Excel).

  • User/customer demographics – if a customer table exists, add state, address, etc.

Example Augmentations in GameZone

  • Purchased year, month, week (from purchase timestamp)

  • Time to ship (in days)

  • Region (from regional lookup table)

  • Remove nonsensical auto-filled values (e.g., Excel converting blanks to year 1900)

After augmentation, perform a final sanity check on the new columns.


Note and Document

The final step ties everything together in an issues log that records:

  • Each issue discovered

  • Whether it was solvable or unsolvable

  • How it was resolved (or why it was left)

  • Percent magnitude affected (e.g., 0.7% duplicates, 10% negative time to ship)

This document serves as a paper trail for stakeholders and demonstrates thoughtfulness as a data analyst to hiring managers.


Summary: The Full CLEAN Process

  1. Conceptualize – understand grain, metrics, dimensions; tell the story of one record.

  2. Locate solvable issues – first pass cleaning: fix formats, spellings, category mismatches, and impute known nulls.

  3. Evaluate unsolvable issues – document magnitude; do not delete or impute without justification.

  4. Augment – add time grains, derived metrics, and external dimensions.

  5. Note and document – finalize issues log with resolutions and impact percentages.

Data cleaning is iterative. The goal is not perfect data but data good enough to yield reliable insights that can be shared and built upon. By following this structured framework, analysts ensure their portfolio projects reflect real-world rigor and transparency.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent