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

Replace Values with a Mapping

Context. A survey used country codes ("US", "UK", "IN") but the final report needs full names.

Your task. Write expand_country_codes(df, mapping) that returns the country column with each code replaced by its full name from the mapping dict.

Example. codes ["US", "IN"], mapping {"US": "United States", "IN": "India"} → ["United States", "India"].

Notes. Codes not in the mapping are left unchanged. Empty mapping → all codes pass through unchanged.

Previous
Clean a Text Column with apply
Next
Sales per Region