I have some data which looks as follows:
Owner Label1 Label2 Label3
Bob Dog N/A N/A
John Cat Mouse N/A
Lee Dog Cat N/A
Jane Hamster Rat Ferret
And I want it reshaped to one-hot encoding. Something like this:
Owner Dog Cat Mouse Hamster Rat Ferret
Bob 1 0 0 0 0 0
John 0 1 1 0 0 0
Lee 1 1 0 0 0 0
Jane 0 0 0 1 1 1
I've looked around the documentation and stackoverflow, but haven't been able to determine the relevant functions to achieve this. get_dummies comes pretty close, but it creates a prefix for each category only when that category appears in a respective column.