Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

target ordinary encodiing)

## Converting range of Age to numeric variable using (target ordinary encodiing)
## Note: Dont map from 0 because of mathematical issue, you should always satart your mapping from 1


df['Age']=df['Age'].map({'0-17':1, 
                         '18-25':2, 
                         '26-35':3, 
                         '36-45':4, 
                         '46-50':5, 
                         '51-55':6, 
                         '55+':7  })
df.head()

#or

## Converting Gender "M" and "F" to numeric variable
## Note: Dont map from 0 because of mathematical issue, you should always satart your mapping from 1

df['Gender']=df['Gender'].map({'F':0, 'M':1})
df.head()
Comment

PREVIOUS NEXT
Code Example
Python :: Using mapping in Converting categorical feature in to numerical features 
Python :: django update request.post 
Python :: rasperry pi camera 
Python :: python async function 
Python :: method for detect that a float number is integer in python 
Python :: machine learning python 
Python :: month name in python 
Python :: c++ call python function 
Python :: how to get a dictionary in alphabetical order python 
Python :: python print last 3 
Python :: python rps 
Python :: python pandas shift last column to first place 
Python :: merge all mp4 video files into one file python 
Python :: python tkinter listbox detect selection change 
Python :: # write json file 
Python :: cv2.flip 
Python :: how to create staff account in django 
Python :: superscript python 
Python :: UnicodeDecodeError: ‘utf8’ codec can’t decode byte 
Python :: np.where 
Python :: how to sort the dataframe in python by axis 
Python :: spotify api python 
Python :: how to add a file to an email in python 
Python :: generate binary number in python 
Python :: python bubble sort 
Python :: Math Module ceil() Function in python 
Python :: tqdm in place 
Python :: scrapy get inside attribute value 
Python :: pandas dataframe get first n rows 
Python :: selenium webdriver options python 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =