Horje
Handling categorical feature Code Example
Handling categorical feature
## 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
pandas add thousands separator Code Example pandas add thousands separator Code Example
pandas save dataframe with list Code Example pandas save dataframe with list Code Example
signals and built in signals in django Code Example signals and built in signals in django Code Example
host python discord bot free Code Example host python discord bot free Code Example
mss python install Code Example mss python install Code Example

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