这是数据帧的子集:
index id drug sentences SS1 SS2
1 2 lex very bad 0 1
2 3 gym very nice 1 1
3 7 effex hard 1 0
4 8 cymba poor 1 1
我想找到SS1和SS2不同的行,然后基于它创建一个新的数据帧。输出应该是这样的:
^{pr2}$这是我的代码:
df [['index','id', 'drug', 'sentences', 'SS1', 'SS2' ]] = np.where(df.SS1 != df.SS2)
但它有以下错误:ValueError: Must have equal len keys and value when setting with an ndarray
有什么建议吗?在
一种方法可能是:
输出:
^{pr2}$使用
where
:相关问题 更多 >
编程相关推荐