相关疑难解决方法(0)

从数组中删除另一个数组中的元素

假设我有这些2D阵列A和B.

如何从B中删除A中的元素.(集合论中的补充:AB)

A=np.asarray([[1,1,1], [1,1,2], [1,1,3], [1,1,4]])
B=np.asarray([[0,0,0], [1,0,2], [1,0,3], [1,0,4], [1,1,0], [1,1,1], [1,1,4]])
#output = [[1,1,2], [1,1,3]]
Run Code Online (Sandbox Code Playgroud)

更确切地说,我想做这样的事情.

data = some numpy array
label = some numpy array
A = np.argwhere(label==0) #[[1 1 1], [1 1 2], [1 1 3], [1 1 4]]
B = np.argwhere(data>1.5) #[[0 0 0], [1 0 2], [1 0 3], [1 0 4], [1 1 0], [1 1 1], [1 1 4]]
out = np.argwhere(label==0 and data>1.5) #[[1 1 2], [1 1 3]]
Run Code Online (Sandbox Code Playgroud)

python arrays numpy

20
推荐指数
4
解决办法
9750
查看次数

标签 统计

arrays ×1

numpy ×1

python ×1