我有以下熊猫系列:
output={'index':[0,1,2,3,4],'output'=[0,1,0,0,1]}
我想将输出列拆分为 2 列“0”和“1”:
index output 0 1
0 0 1 0
1 1 0 1
2 0 1 0
3 0 1 0
4 1 0 1
然后,我想删除输出列,只剩下 3 列:索引、0 和 1
我试过这个丑陋的代码:
for i in output:
if i==0:
output['0'],ouput['1']=1,0
else:
output['0'],ouput['1']=0,1
但它只在我的系列末尾添加了 2 行。