Problem 2: Apply Label Encoding with a Custom Order
Easypython
Problem Description
Write a Python program that encodes an ordinal "education_level" column ("High School," "Bachelor's," "Master's") into integers that respect their true logical order (0, 1, 2).
Input
A DataFrame with an "education_level" column.
Output
The DataFrame with an additional numeric "educationlevelencoded" column.
Constraints
- Only these three education levels will appear.
Example Input
text{"education_level": ["Bachelor's", "High School", "Master's"]}
Example Output
texteducation_level education_level_encoded 0 Bachelor's 1 1 High School 0 2 Master's 2
Concepts Covered
Custom dictionary mapping, .map().