1

我正在尝试使用 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 中实现它?

4

1 回答 1

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]),)
于 2012-10-10T21:28:53.150 回答