Skip to content

About

QL data cleaning project on a global tech layoffs dataset-deduplication, standardization, and null handling in MySQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Layoffs Dataset: SQL Data Cleaning Project

Overview

This project takes a raw, messy dataset of global tech layoffs and cleans it into an analysis-ready state using MySQL. It was my first hands-on SQL project, built while following Alex The Analyst's Data Analyst bootcamp series on YouTube, and it's the foundation for further exploratory analysis on the same dataset.

Why data cleaning matters

Raw data is rarely usable as-is. This dataset had duplicate rows, inconsistent text formatting, dates stored as text, and a mix of NULL and blank values across columns. Before any analysis or visualization can be trusted, these issues have to be resolved systematically, not ad hoc, so the process is repeatable and auditable.

Process

The cleaning followed five stages:

  1. Staging table — copied the raw data into a working table so the original source stays untouched.
  2. Duplicate removal — used ROW_NUMBER() with a PARTITION BY across every column to flag exact duplicate rows, then deleted the extras.
  3. Standardization — trimmed stray whitespace from company names, merged inconsistent category labels (e.g. multiple "Crypto" variants into one), fixed a trailing-period typo in "United States", and converted the date column from text to a proper DATE type.
  4. Null handling — converted blank strings to true NULLs, then backfilled missing industry values by matching other rows from the same company and location. Removed rows with no usable layoff figures at all.
  5. Final structure — dropped the helper column used for deduplication, leaving a clean table ready for analysis.

Skills demonstrated

  • Window functions (ROW_NUMBER() OVER (PARTITION BY ...))
  • Common Table Expressions (CTEs)
  • Self-joins for data backfilling
  • String functions (TRIM, pattern matching with LIKE)
  • Date parsing and type conversion (STR_TO_DATE, ALTER TABLE ... MODIFY)
  • Systematic, staged approach to data cleaning that preserves the raw source

Notes / things I'd improve next time

  • The date conversion assumes all values are in MM/DD/YYYY format — worth validating that assumption against the full dataset rather than a sample before applying it.
  • The industry backfill matches on company and location, since matching on company alone risked pulling an industry from a different branch of the same company.

Data

  • data/layoffs_raw.csv — original dataset before cleaning (~2,361 rows)
  • data/layoffs_cleaned.csv — dataset after running the cleaning script (~1,000 rows, after removing duplicates and unusable rows)
  • Source dataset provided as part of Alex The Analyst's Data Analyst bootcamp series on YouTube.

Files

  • layoffs_data_cleaning.sql — full cleaning script, commented step by step
  • data/ — raw and cleaned versions of the dataset

What's next

Exploratory data analysis on the cleaned table: trends by industry, company stage, country, and time.

About

QL data cleaning project on a global tech layoffs dataset-deduplication, standardization, and null handling in MySQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors