Comments

Convert categorical variable to quantitative variable

-One-hot encoding: 

 Add dummy variable (A, B, C,..) for each unique category or assign 0,1 for each category, for example, let's have two types of fuel (gas, diesel) so when a car has fuel type gas we assign gas to 1 and diesel to 0.

The Code: 

pd.get_dummies(df['column_name'])
 

the result will be a table of two-column with 0,1 values.
Share on Google Plus

About Inas AL-Kamachy

    Blogger Comment
    Facebook Comment

0 Comments:

Post a Comment