Aug-21-2017, 09:12 AM
Hi, I'm trying to loop through two lists.
I want to compare the arrays in the list 'center' to the arrays in the larger list 'mail_vecs'.When the array is the same I want to return the index of the array in mail_vecs that is the same as the array in 'center'.
The shape of 'center'is (15, 100)
The shape of 'mail_vecs' is (271304, 100)
I'm not sure how to do this as I'm rather new to using python. I tried something but I know it is not good. Thanks in advance!
I want to compare the arrays in the list 'center' to the arrays in the larger list 'mail_vecs'.When the array is the same I want to return the index of the array in mail_vecs that is the same as the array in 'center'.
The shape of 'center'is (15, 100)
The shape of 'mail_vecs' is (271304, 100)
I'm not sure how to do this as I'm rather new to using python. I tried something but I know it is not good. Thanks in advance!
index_center = [] for vec2 in np.nditer(center): for index, vec1 in enumerate(np.nditer(mail_vecs)): if np.array_equal(vec1, vec2): index_center.append(index) print(np.shape(index_center))