Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Pandas Get_dummies for nested tables

$
0
0

I am looking to utilize pandas get_dummy() functionality to encode a (quite extensive) set of categorical variables. However the data is currently in nested table format. Meaning that each row represents another variable instance for example

Instance, Cat_Col1, John1, Smith2, Jane3, Joe

Now I can generate the full list of unique variables which I can use to get_dummies which represent all possible values. However transforming the nested table into a single instance row in this new format is giving me some trouble.

Any help is much appreciated Thanks

Edit: each instance should have a dummy coding result for all values of Cat_col

The idea would be the result be a single feature vector like so

Instance,Col_John,Col_Smith,Col_Jane,Col_Joe1,1,1,0,02,0,0,1,03,0,0,0,1

I believe that is the correct coding, assuming we are doing 1-hot encoding


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>