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
$\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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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