我正在尝试使用python比较一维数组集合中的一维数组。例如:
import numpy as np;
data= np.array( [ [1,2] , [2,3] ,[3,4], [1,2] , [0,9] ])
#I want to get the indexes of [1,2] which are 0 and 3 for above list
有没有人知道如何在python中实现它?
答案 0 :(得分:4)
In [116]: data = np.array( [ [1,2] , [1,3] ,[3,4], [1,2] , [0,9] ])
In [117]: np.where(np.prod(data == [1,2], axis = -1))
Out[117]: (array([0, 3]),)