在两个numpy数组中查找匹配行的索引
如何找到两个numpy数组之间完全匹配的行的索引。例如:在两个numpy数组中查找匹配行的索引,numpy,Numpy,如何找到两个numpy数组之间完全匹配的行的索引。例如: x = np.array(([0,1], [1,0], [0,0])) y = np.array(([0,1], [1,1], [0,0])) 这应返回: matches = [0,2] # Match at row no 0 and 2 或: 或: 如果长度相同,则这适用于每对numpy阵列: matches = [i f
x = np.array(([0,1],
[1,0],
[0,0]))
y = np.array(([0,1],
[1,1],
[0,0]))
这应返回:
matches = [0,2] # Match at row no 0 and 2
或:
或:
如果长度相同,则这适用于每对numpy阵列:
matches = [i for i in range(len(x)) if x[i].tolist()==y[i].tolist()]
np.nonzero((x == y).all(1))[0]
np.where((x == y).all(1))[0]
matches = [i for i in range(len(x)) if x[i].tolist()==y[i].tolist()]