Clean Data

More Information
  • Understand the role of data cleaning in the overall data science process
  • Learn the basics of file formats, data types, and character encodings to clean data properly
  • Master critical features of the spreadsheet and text editor for organizing and manipulating data
  • Convert data from one common format to another, including JSON, CSV, and some special-purpose formats
  • Implement three different strategies for parsing and cleaning data found in HTML files on the Web
  • Reveal the mysteries of PDF documents and learn how to pull out just the data you want
  • Develop a range of solutions for detecting and cleaning bad data stored in an RDBMS
  • Create your own clean data sets that can be packaged, licensed, and shared with others
  • Use the tools from this book to complete two real-world projects using data from Twitter and Stack Overflow

Is much of your time spent doing tedious tasks such as cleaning dirty data, accounting for lost data, and preparing data to be used by others? If so, then having the right tools makes a critical difference, and will be a great investment as you grow your data science expertise.

The book starts by highlighting the importance of data cleaning in data science, and will show you how to reap rewards from reforming your cleaning process. Next, you will cement your knowledge of the basic concepts that the rest of the book relies on: file formats, data types, and character encodings. You will also learn how to extract and clean data stored in RDBMS, web files, and PDF documents, through practical examples.

At the end of the book, you will be given a chance to tackle a couple of real-world projects.

  • Grow your data science expertise by filling your toolbox with proven strategies for a wide variety of cleaning challenges
  • Familiarize yourself with the crucial data cleaning processes, and share your own clean data sets with others
  • Complete real-world projects using data from Twitter and Stack Overflow
Page Count 272
Course Length 8 hours 9 minutes
ISBN 9781785284014
Date Of Publication 24 May 2015
Understanding the HTML page structure
Method one – Python and regular expressions
Method two – Python and BeautifulSoup
Method three – Chrome Scraper
Example project – Extracting data from e-mail and web forums
Why is cleaning PDF files difficult?
Try simple solutions first – copying
Another technique to try – pdfMiner
Third choice – Tabula
When all else fails – the fourth technique
Getting ready
Step one – download and examine Sentiment140
Step two – clean for database import
Step three – import the data into MySQL in a single table
Step four – clean the & character
Step five – clean other mystery characters
Step seven – separate user mentions, hashtags, and URLs
Step eight – cleaning for lookup tables
Step one – posing a question about Stack Overflow
Step two – collecting and storing the Stack Overflow data
Step three – cleaning the data
Step four – analyzing the data
Step five – visualizing the data
Step six – problem resolution
Moving from test tables to full tables
Step one – posing a question about an archive of tweets
Step two – collecting the data
Step three – data cleaning
Step four – simple data analysis
Step five – visualizing the data
Step six – problem resolution
Moving this process into full (non-test) tables


Megan Squire

Megan Squire is a professor of computing sciences at Elon University.

Her primary research interest is in collecting, cleaning, and analyzing data about how free and open source software is made. She is one of the leaders of the,, and projects.