【发布时间】:2019-11-27 04:08:02
【问题描述】:
我尝试将单词从 DataFrame Columns 中分离出来:
Binary = []
for i in range(0,len(data)):
if data['attack'][i] == 'normal':
Binary.append(1)
else:
Binary.append(0)
print(len(Binary))
data= pd.DataFrame({'attack':['normal','neptune','ps','normal','neptune']})
print(data)
attack
0 normal
1 neptune
2 ps
3 normal
4 neptune
我们想将这些列值更改为: ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。
attack
0 1
1 0
2 0
3 1
4 0
只有正常 = 1 否则 0
【问题讨论】: