2017-09-14 146 views

回答

2
np.flatnonzero((x == y).all(1)) 
# array([0, 2]) 

或:

np.nonzero((x == y).all(1))[0] 

或:

np.where((x == y).all(1))[0] 
0

這適用於每對numpy陣列,如果長度相同:

matches = [i for i in range(len(x)) if x[i].tolist()==y[i].tolist()]