Explore Courses Blog Tutorials Interview Questions
0 votes
in Data Science by (17.6k points)

I want to one-hot encode multiple columns in my data frame at once using Keras to_categorical. How to do it?

need_to_encode = ['Item_Fat_Content', 'Outlet_Location_Type', 'Outlet_Type', 'Outlet_Size', 'Item_Type_Combined', 'Outlet']

These are the columns I need to one-hot encode.

1 Answer

0 votes
by (41.4k points)


For the columns that need encoding of the data, you can use util function.

 You can also use scikit-learn's categorical encoder on the part of the dataframe you need to encode.

If you wish to learn about scikit learn then visit this Scikit Learn Tutorial.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories