BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 3: Importing & Handling Files/CSV Cleanup3/3
Exercise·7 min·10 XP

Tidy Column Headers

Context. A CSV arrived with messy column headers — stray spaces, inconsistent casing, spaces inside names — making columns awkward to reference.

Your task. Write tidy_headers(df) that returns the DataFrame with every column name cleaned: surrounding whitespace stripped, lowercased, and inner spaces replaced with underscores.

Example. " First Name " → "first_name", "AGE" → "age".

Notes. Only the headers change — the row data is untouched. Already-clean headers stay as they are.

Previous
Remove Duplicate Rows
Next
Fix a Numeric Column