Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 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 中实现它?
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]),)