When label encoding numbers
[1, 1, 2, 6]
LabelEncoder return [0,0,1,2] because it sorts the classes
What's the best possible way to get [1,1,0,2] by preserving the original order
Tried - CategoricalIndex, which works the same way
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
le.fit([2, 1, 2, 6])
# le.classes_ [1,2,6]
le.transform([1, 1, 2, 6])