Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Changing categorial into numerical variables

$
0
0

@ASHISH_17 wrote:

I am trying to change categorial into numerical variable but getting this error -

FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison

Code is-

train[‘Married’][train[‘Married’]==“No”]=0
train[‘Married’][train[‘Married’]==“Yes”]=1
train[‘Gender’][train[‘Gender’]==“Male”]=1
train[‘Gender’][train[‘Gender’]==“Female”]=0
train[‘Dependents’][train[‘Dependents’]==0]=0
train[‘Dependents’][train[‘Dependents’]==1]=1
train[‘Dependents’][train[‘Dependents’]==2]=2
train.Dependents[train.Dependents>=3]=3
train[‘Education’][train[‘Education’]==“Graduate”]=1
train[‘Education’][train[‘Education’]==“Not Graduate”]=0
train[‘Self_Employed’][train[‘Self_Employed’]==“Yes”]=1
train[‘Self_Employed’][train[‘Self_Employed’]==“No”]=0
train[‘Property_Area’][train[‘Property_Area’]==“Rural”]=1
train[‘Property_Area’][train[‘Property_Area’]==“Semiurban”]=2
train[‘Property_Area’][train[‘Property_Area’]==“Urban”]=3

How to correct it ?

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles