11

Tidying and Reshaping Data

Echoing Leo Tolstoy’s wisdom (“Happy families are all alike; every unhappy family is unhappy in its own way.”), Hadley Wickham tells us, all tidy data is fundamentally alike, but all untidy data is messy in its own special way. How many times have we all stared at some rows of data and thought, “What… how... why did they do that?” This overstates the case somewhat. Although there are many ways that data can be poorly structured, there are limits to human creativity in this regard. It is possible to categorize the most frequent ways in which datasets deviate from normalized or tidy forms.

This was Hadley Wickham’s observation in his seminal work on tidy data. We can lean on that work, and our own experiences with ...

Get Python Data Cleaning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.