Course contentsShow
← Data Science
Lesson 1144 of 2,14529. Data Wrangling WorkflowsFree lesson

Common Violations: Wide vs Long Format

Identify when data is too wide (variables spread across columns) or needs reshaping for tidy analysis.

Common Violations: Wide vs Long Format

You'll learn how to spot when your data is too spread out across columns ("wide") or needs to be reshaped into a tidy, analysis-friendly structure.

The Core Problem

When working with real-world data, you'll often encounter datasets that violate the three rules of tidy data you just learned. Two of the most common violations involve format:

Wide format spreads observations across multiple columns. Imagine a table tracking monthly sales where each month gets its own column: Jan, Feb, Mar, etc. Here, the variable "month" isn't stored in one column—it's scattered across many column names. This makes filtering, grouping, and plotting awkward.

Long format (the tidy version) stacks these observations vertically, using one column for the variable name (month) and another for its value (sales). Each row becomes a single observation.

When Data Is Too Wide

Common signs your data is too wide:

  • Column names contain data values (like years: 2020, 2021, 2022)
  • You have many columns representing the same type of measurement
  • Simple operations require complex column-by-column logic

When Data Needs Reshaping

If you find yourself thinking "I wish all these columns were in one place so I could group by them," your data probably needs to go from wide to long.

Analogy: Think of wide format like a spreadsheet optimized for human reading—everything visible at once. Long format is optimized for computers—each piece of information has its own clearly labeled row.

Key Takeaway: Wide format spreads variables across columns (human-readable but analysis-hostile), while long format stacks observations vertically with explicit variable columns (tidy and tool-friendly). Recognizing this violation is the first step toward effective data wrangling.