liveBook · Manning

Long data

As explained in The Well-Grounded Data Analyst

Long data is a tabular representation in which each row records one measurement or entity-participation observation.

Long data stores one observation per row: a measurement or an entity’s participation in an event. Repeated attributes that would occupy separate columns in a wide table become values in shared columns, while identifiers and context remain alongside each observation. section 3.1.1

Choose the structure for the analytical question, not as a cosmetic cleanup. Long data can make it easier to compare categories, change granularity, and build cross-tabulations; the resulting model should capture transformations that would otherwise be repeated for every analysis. section 3.1.1 section 6.4.2

Representing football results

A wide match record has separate Home team, Away team, Home goals, and Away goals columns. A long version uses two rows per match: one for each team, with a Home or away? value and a Goals scored value. Match details such as date, competition, and round are repeated for both participants. section 3.1.1

For multiple-choice survey responses, first turn selections into indicator columns, then gather each selected option’s counts by response category into a long table. That table can be reshaped into percentage cross-tabs and displayed as a heatmap, making comparisons across use cases easier to inspect. section 6.4.2

Table 3.2 The same football results in a long format, one row per match participant
Match ID
Date
Competition
Round
Team
Home or away?
Goals scored
1
2014-07-04
World Cup 2014
Quarter-final
France
Home
0
1
2014-07-04
World Cup 2014
Quarter-final
Germany
Away
1
2
2014-07-04
World Cup 2014
Quarter-final
Brazil
Home
2
2
2014-07-04
World Cup 2014
Quarter-final
Colombia
Away
1
3
2014-07-05
World Cup 2014
Quarter-final
Argentina
Home
1
3
2014-07-05
World Cup 2014
Quarter-final
Belgium
Away
0

Compare the two participant rows for each match with the single wide match record: team role and goals are values rather than paired home/away columns. section 3.1.1

Figure 6.38 A snapshot of long-format data comparing AI tool use case options with trustworthiness
figure

Inspect a long-form survey artifact in which AI tool-use options are paired with trustworthiness response counts before cross-tabulation. section 6.4.2

How The Well-Grounded Data Analyst covers it

How deep it goes
Defines long versus wide structure and demonstrates reshaping survey indicators into a long table before crosstabs and heatmaps.
Examples
Uses football matches with one row per participant and survey AI-use options grouped by favorability or trustworthiness.
What you can do after
Apply it via pandas to prepare category cross-tabs and heatmaps from repeated survey-option analyses.
How it connects
Connects data modeling, wide data, data cleaning, granularity, categorical data, cross-tabulation, and heatmaps.

Also explained in

Compare how 2 books explain long data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.