I have a banking_dataframe
with 21 different columns, one is target, 10 of them are numeric features and 10 of them are categorical features. I have used get_dummies
method of pandas to convert categorical data to one-hot encoding.
The returned dataframe has 74 columns. Now, I want to merge the encoded dataframe with the original data frame, so my final data should have one-hot encoded values for categorical columns but in the original size of data-frame i.e; 21 columns.
Link to get_dummies function of Pandas:
Code snippet to call get_dummies
on categorical features
encoded_features = pd.get_dummies(banking_dataframe[categorical_feature_names])
pd.concat
withaxis=1
? – Quang Hoangbanking_dataframe.join(pd.get_dummies(banking_dataframe[categorical_feature_names])
? – political scientist