Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (120 points)
# # Encoding categorical data & Feature Scaling

# Select the categorical columns
categorical_subset = credit[['Term', 'Years in current job', 'Home Ownership', 'Purpose']]

# One hot encode
categorical_subset = pd.get_dummies(categorical_subset)

# Join the dataframe in credit_train
# Make sure to use axis = 1 to perform a column bind
# First I will drop the 'old' categorical datas and after I will join the 'new' one.

credit.drop(labels=['Term', 'Years in current job', 'Home Ownership', 'Purpose'], axis=1, inplace=True)
credit = pd.concat([credit, categorical_subset], axis = 1)
pd.get_dummies(categorical_subset) This statement is not showing any dummy ... it only shows the original columns.... ? Is it also okay to do OneHotEncoding in this way...?

Please log in or register to answer this question.

Browse Categories