如何将带有“枚举”字符串的pandas DataFrame列拆分为几个二进制列?

时间:2019-12-12 19:32:38

标签: python pandas

我有一个熊猫dataframe对象,该对象的列为feature,列的值可能为'A''B''C'。我想将其拆分为3个二进制列,以便下面的dataframe

otherColumn feature
value1      A
value2      B
value3      C

转到:

otherColumn featureA featureB featureC
value1      1        0        0
value2      0        1        0
value3      0        0        1

是否有一种可以快速完成此任务的方法?

0 个答案:

没有答案