Using saved mappings
You are using a subset of a dataset and have been asked to create visualizations summarizing the output. As the dataset currently stands, all you see are numbers! Luckily, you had created and saved dictionaries (color_map
, fuel_map
, and transmission_map
) that will map these columns back to their original categorical names. The dataset used_cars_updated
has been preloaded. A preview of the dataset is shown. Check out the console to view the column data types.
engine_fuel color transmission price_usd
0 3 8 0 10900.00
1 3 1 0 5000.00
2 3 7 0 2800.00
This exercise is part of the course
Working with Categorical Data in Python
Exercise instructions
- Update the
"color"
column back to its original values using thecolor_map
dictionary. - Update the
"engine_fuel"
column back to its original values using thefuel_map
dictionary. - Update the
"transmission"
column back to its original values using thetransmission_map
dictionary. - Use
.info()
on the dataset to see if thedtypes
have changed.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Update the color column using the color_map
used_cars_updated["color"] = ____
# Update the engine fuel column using the fuel_map
used_cars_updated["engine_fuel"] = ____
# Update the transmission column using the transmission_map
used_cars_updated["transmission"] = ____
# Print the info statement
print(____)