Horje
target ordinary encodiing) Code Example
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()




Python

Related
how to set class attributes with kwargs python Code Example how to set class attributes with kwargs python Code Example
folium add a polygon to a map Code Example folium add a polygon to a map Code Example
get data from keyboard python Code Example get data from keyboard python Code Example
convert xls to xlsx python Code Example convert xls to xlsx python Code Example
Math expressions with matplotlib Code Example Math expressions with matplotlib Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8