如a (array([1, 2, 6], dtype=int64),) b (array([1, 2, 4, 8], dtype=int64),) 求在a中有b中没有的结果
3 回答

心有法竹
TA贡献1866条经验 获得超5个赞
>>> a = np.array([1, 2, 3, 2, 4, 1])
>>> b = np.array([3, 4, 5, 6])
>>> np.setdiff1d(a, b)
array([1, 2])

守着星空守着你
TA贡献1799条经验 获得超8个赞
1 2 3 4 5 6 7 8 9 | #py2.7 #coding=utf-8 import numpy as np a = np.array([1, 2, 6],dtype=np.int64) b = np.array([1, 2, 4, 8],dtype=np.int64) print list(set(a)-set(b)) >>> [6] >>> |

红糖糍粑
TA贡献1815条经验 获得超6个赞
1 2 3 4 5 6 7 8 9 | >>> import numpy as np >>> a = np.array([1, 2, 6]) >>> b = np.array([1, 3, 6]) >>> ### 交集 >>> np.intersect1d(a,b) array([1, 6]) >>> ### 差集 >>> np.setdiff1d(a,b) array([2]) |
- 3 回答
- 0 关注
- 1746 浏览
添加回答
举报
0/150
提交
取消