My data frame is like below:
a
0 [8, 10]
1 [12, 7, 9]
As you can see column a contains a list. Number inside that list has meaning in our domain and i want to use them as feature. My expected output is like below:
Tag_7 Tag_8 Tag_9 Tag_10 Tag_12
0 0 1 0 1 0
1 1 0 1 0 1
I used some methods that i find from internet they satisfy my expectation but there is a execution time problem with that methods. One of them is like below:
pd.get_dummies(df.a.apply(pd.Series).stack().astype(int), prefix='Tag').sum(level=0)
I think this method is useful for small datasets. For my case it is not useful. I need help. Thanks in advance. Have a nice day