Skip to content
Advertisement

How to create dummies for certain columns with pandas.get_dummies()

JavaScript

I just want Column A and D to get dummies not for Column B. If I used pd.get_dummies(df), all columns turned into dummies.

I want the final result containing all of columns , which means column C and column B exit,like 'A_x','A_y','B','C','D_j','D_l'.

Advertisement

Answer

It can be done without concatenation, using get_dummies() with required parameters

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement