Last answered:

06 Apr 2020

Posted on:

05 Apr 2020

0

converting Categorical data to numerical.

How to convert Categorical data into numerical in python? as you already converted in segmentation data for example, unemployed=0                          employed=1                     Highly skilled=2
1 answers ( 0 marked as helpful)
Instructor
Posted on:

06 Apr 2020

0
Hi Ganesh,  one approach would be to do a mapping of the variables in the form of dictionary, like you suggested unemployed becomes 0, etc. :
dict = {"occupation":     {"unemployed": 1, ...}

Then you can use the replace() method on your data frame to directly assign the new values:
your_data.replace(dict, inplace=True)
Here's a link with more on the topic: https://pbpython.com/categorical-encoding.html   Best,  Eli

Submit an answer