Editor

Predict the Pipeline Output

Intermediate · Predict the output · from Build an Automated Data Cleaning Pipeline

From the lesson: Step 7: Understanding the Pipeline Flow

Before we build the final pipeline, let's make sure you understand how the steps chain together. Each cleaning function takes a DataFrame and returns a cleaned version. The output of one step becomes the input to the next.

Read this part of the lesson

What does this code print? Think about each step carefully.

import pandas as pd

data = {'name': ['  alice  ', 'BOB', '  alice  ', None],
        'score': [10, 20, 10, 30]}
df = pd.DataFrame(data)

# Step 1: Drop missing names
df = df.dropna(subset=['name'])

# Step 2: Standardize names
df['name'] = df['name'].str.strip().str.title()

# Step 3: Remove duplicates
df = df.drop_duplicates(subset=['name'])

print(len(df))
print(df['name'].tolist())
# What does this code print?
# Type your answer as two print statements:
# First: the length
# Second: the list of names
print(2)
print(['Alice', 'Bob'])

More Data Cleaning Pipeline exercises

All Python exercises · 50 practice problems · Practical Projects quiz