[英]matching 1d arrays in 2d arrays in python
I am trying to compare a one dimensional array in a collection of 1 dimensional array using python. 我试图使用python比较一维数组集合中的一维数组。 For example:
例如:
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
Does anyone have an idea how to implement that in python? 有没有人知道如何在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]),)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.