Home > Software design >  How do I encode categorical values in a Pandas DataFrame using a dictionary scheme given in an Excel
How do I encode categorical values in a Pandas DataFrame using a dictionary scheme given in an Excel

Time:02-10

I have a Pandas DataFrame with a key attribute and other categorical attributes. How can I encode the categorical attributes using the 'dictionary' in this excel file?

enter image description here

I created the excel file, but you need just to read that using read_excel.

Based on the comments:

def autodic(string):
  temp = string.replace(';', '",').replace(':', ':"')
  temp = '{' temp '"' '}'
  return eval(temp)
  • Related