我有以下数据框:
Text Label
"Some Text" "CategoryA"
"Some Text" "CategoryB"
"New Text" "CategoryA"
"Other Text" "CategoryC"
我想将其(热编码一次)转换为:
Text CategoryA CategoryB CategoryC
"Some Text" 1 1 0
"New Text" 1 0 0
"Other Text" 0 0 1
我尝试使用 pivot_table ,但无济于事。