1
$\begingroup$
places = ['India','France','India','Australia','Australia','India','India','France']

Here places are the DataFrame Series, now how can I find that which label was encoded with values like India = 0 , Australia = 1 ,France = 2. This is ok for few labels what if there are 100's of labels available in a huge dataset.

$\endgroup$

1 Answer 1

2
$\begingroup$

Use the classes_ attribute of your LabelEncoder. For example:

le = preprocessing.LabelEncoder()
le.fit(places)
print(le.classes_)

The index of the label in le.classes_ is the encoded value of the label. See another example here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.