I am looking for a way to convert column values of my dataframe to boolean values. In my dataframe below, I have columns x,y,z.
I prepared a reference dict where I got all the unique values from each column, sorted and separated by colons. Finally, I concatenated my dict with the dataframe: Here is what my dict looks like: {'x':'0:1:10','y':'5:10','z':'0:10:300'}.
Now taking these sorted dict values as a reference, I want to change my column values into binary code (as below in desired output).
My dataframe:
_______________________________
| x | y | z |
| 0:1:10 | 5:10 | 0:10:300 |
_______________________________
A | 0,1 | 10 | 10,300 |
B | 1 | 5 | 300,0 |
C | 10,0,1 | | 300,10 |
________________________________
This is what my desired dataframe with binary coding looks like.
Desired output:
______________________________
| x | y | Z |
| 0:1:10 | 5:10 | 0:10:300 |
______________________________
A | 110 | 01 | 011 |
B | 010 | 10 | 101 |
C | 111 | 00 | 011 |
_______________________________
Thanks,Rtut