我有这样的DataFrame,
df
col1 col2
0 ["dog","cata","snake"] Animal
1 ["cup","plate","tray"] Dish
2 ["human", "dog"] Mammel
现在,我想为列表中的所有元素创建虚拟对象,
df
dog cat snake cup plate tray human col2
0 1 1 1 0 0 0 0 Animal
1 0 0 0 1 1 1 0 Dish
2 1 0 0 0 0 0 1 Mammel
您还可以看到,我没有为其他列表创建重复的列。