TransWikia.com

How to play with .cat.codes and get_dummies

Data Science Asked by Chandraraj Singh on August 10, 2020

I may be lost here and this might be a stupid question.
I know that get_dummies returns multiple columns depending upon the number of variables and .cat.code returns a single column with unique integers per unique value(Please correct me if I’m wrong).
I know fro .cat.codes is for categorical data and get_dummies is for object.


Can I use astype("Category") on an object and use .cat.codes on it?
Anything more that you know of to make analysis(and visualization) easier when it comes to these funtions?

One Answer

You can convert object dtype to category using astype("Category") and then do label encoding on it using .cat.codes but it's better to use sklearn.preprocessing.LabelEncoder for it.

For basic analysis you should look into seaborn

Answered by prashant0598 on August 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP