I want all the columns one hot encoded without the need of listing out the columns or apply one hot encode one by one. I know how to do it one column then another.

enter image description here


You can use:: pandas.get_dummies

get_dummies will only convert string columns and will keep numerical columns as it is. You can first convert categorical columns into string type and then apply get_dummies.

concated_dataset['1stFlrSF'] = concated_dataset['1stFlrSF'].astype("string")
|improve this answer|||||
  • $\begingroup$ Yeah then first convert all the columns you want to be one hot encoded into string type and then apply get_dummies on the whole dataframe. $\endgroup$ – Preet Mar 12 '19 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.