BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/Transform Columns1/3
Exercise·7 min·10 XP

Clean a Text Column with apply

Context. A user table where names are messy (" alice ", "BOB"); clean each to a consistent format.

Your task. Write clean_names(df) that returns the name column with each value stripped of surrounding whitespace and converted to title case.

Example. " alice " → "Alice". "BOB" → "Bob". " JANE doe" → "Jane Doe".

Notes. Use .apply() to run a function across the column. Empty df → empty Series.

Previous
Convert Column to Float
Next
Replace Values with a Mapping