我有两个内部带有数组的Python数组:
first = [[0,10],[0,11],[0,12],[0,13]]
second = [[0,10],[0,11]]
我希望得到的结果是第一个数组中的数组,而不是另一个中的数组:
difference(first,second)
#returns [[0,12],[0,13]]
目前它们是Numy数组,但具有规则数组的解决方案也是有效的.
我try 使用np.setdiff1d
,但它返回了一个带有独占整数的数组,而不是独占array.
我试图遍历第二个数组,删除第一个数组中的元素:
diff = first.view()
for equal in second:
diff = np.delete(diff, np.where(diff == equal))
但它返回了类似的、没有用的结果