Get startedGet started for free

Create a label encoding and map

A used car company believes that they can predict a car's sales price reasonably well using their used_cars dataset. One of the variables they want to use, "color", needs to be converted to codes. The company believes that a car's color will be important when predicting sales price.

This exercise is part of the course

Working with Categorical Data in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Convert to categorical and print the frequency table
used_cars["color"] = ____
print(used_cars["color"].value_counts())
Edit and Run Code