Label Encoding

Medium
feature-engineering PayPal Salesforce

Convert categorical string values to integer labels. Assign integers based on sorted order of unique values.

Example

label_encode(["cat", "dog", "cat", "bird"])
# => [1, 2, 1, 0]  (bird=0, cat=1, dog=2)

Test Cases

Python Editor

Output

Click "Run" to see results...