This question already has an answer here:

I have a query that I perform, I have a dataset that has several categorical features with thousands of levels.

Applying get_dummies would generate a dataset that I could not work with. I would be interested to make selection of the most important levels ​​and the rest of levels ​​of less importance group them. Then i can apply get_dummies.

Do you have any idea how to do this?

It is possible to apply chi squared to the levels ​​of the categorical features instead of to the own features.

I usually use python and scikit learn.


marked as duplicate by kjetil b halvorsen, Michael Chernick, Momo, John, Peter Flom - Reinstate Monica May 18 '17 at 11:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.