Encode each comma separated value in Pandas

I have a dataset

Inp1    Inp2        Inp3               Output
A,B,C   AI,UI,JI    Apple,Bat,Dog      Animals
L,M,N   LI,DO,LI    Lawn, Moon, Noon   Noun
X,Y     AI,UI       Yemen,Zombie       Extras

For these values, I need to apply a ML algorithm. Hence need an encoding technique. Tried a Label encoding technique, it encodes the entire cell to an int for eg.

Inp1    Inp2    Inp3    Output
5       4       8       0

But I need a separate encoding for each value in a cell. How should I go about it.

Inp1     Inp2    Inp3      Output
7,44,87  4,65,2  47,36,20  45

Integers are random here.

Topic categorical-encoding one-hot-encoding python-3.x pandas categorical-data

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.