0

I encode my data by using defaultdict, this is my code:

from collections import defaultdict

d = defaultdict(LabelEncoder)
df_del = df.drop(columns=['DEPTN'])

df_encoded = df_del.apply(lambda x: d[x.name].fit_transform(x))
inverse = df_encoded.apply(lambda x: d[x.name].inverse_transform(x))

How to combine this together to see the mapping of values?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
S makarov
  • 3
  • 3

1 Answers1

0

a simple straight forward way to print all of the labelEncoder's key-values

for i in d:
    print(i)
    print(dict(zip(d[i].classes_, d[i].transform(d[i].classes_))))

inspired by this solution: Any way to get mappings of a label encoder in Python pandas?

Guy Louzon
  • 1,175
  • 9
  • 19