Editor

Load and Inspect the Data

Intermediate · Write the code · from Build an Automated Data Cleaning Pipeline

From the lesson: Step 1: Load the Messy Data

Every data cleaning project starts with loading the data and taking a first look. Our dataset is a customer list from a fictional online store. It has all the typical problems you'd see in real data pulled from a database or CSV export.

Read this part of the lesson

Create the messy DataFrame from the provided dictionary and print a summary showing:

1. The number of rows and columns

2. The count of missing values per column

Print the output in this exact format:

Rows: 10, Columns: 5
Missing values:
name              2
email             1
age               0
signup_date       1
purchase_total    1

Note: The name column has one None value and one whitespace-only value " Eve Adams " is NOT missing (it has content). However, the None counts as 1 missing. Look at the data carefully.

import pandas as pd
data = {
'name': ['Alice Smith', 'bob jones', 'CHARLIE BROWN', 'Alice Smith',
'Diana Prince', ' Eve Adams ', None, 'frank miller', 'Grace Lee', 'bob jones'],
'email': ['alice@email.com', 'bob@email.com', 'charlie@email.com', 'alice@email.com',
'diana@email', 'eve@email.com', 'unknown@email.com', None, 'grace@email.com', 'bob@email.com'],
'age': [28, 'thirty-two', 45, 28, 35, -5, 22, 150, 31, 'thirty-two'],
'signup_date': ['2024-01-15', '01/20/2024', '2024-02-01', '2024-01-15',
'March 5, 2024', '2024-03-10', '2024-03-15', '2024-04-01', None, '01/20/2024'],
'purchase_total': [150.0, 200.0, None, 150.0, 89.99, 320.0, 45.0, 1200.0, 175.50, 200.0]
}
# Create the DataFrame and print the summary

More Data Cleaning Pipeline exercises

All Python exercises · 50 practice problems · Practical Projects quiz