Editor

Predict the String Operation Output

Intermediate · Predict the output · from Pandas String and DateTime Operations for Real-World Data

From the lesson: Pandas String and DateTime Operations for Real-World Data

Real-world data is messy. Names arrive in ALL CAPS, dates come as random text strings like "Jan 5, 2024" or "2024/01/05", and phone numbers have dashes in some rows but not others. Before you can analyze anything, you need to clean this stuff up.

Read the lesson

What will this code print?

import pandas as pd
s = pd.Series(['hello world', 'foo bar', 'python pandas'])
print(s.str.split(' ').str.get(0).str.upper().tolist())
# Type the exact output

More Pandas String and Datetime exercises

All Python exercises · 50 practice problems · Data Science & Machine Learning quiz