Python Forum
Looping through multidimensional array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping through multidimensional array
#1
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!

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))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Counting Element in Multidimensional List quest_ 1 2,099 Nov-25-2020, 10:00 PM
Last Post: quest_
  Choose an element from multidimensional array quest_ 2 2,621 Nov-25-2020, 12:59 AM
Last Post: quest_
  Jelp with a multidimensional loop Formationgrowthhacking 1 1,843 Jan-27-2020, 10:05 PM
Last Post: micseydel
  Sort MULTIDIMENSIONAL Dictionary mirinda 2 4,885 Apr-05-2019, 12:08 PM
Last Post: perfringo
  deleting certain rows from multidimensional list aster 4 14,328 Nov-05-2017, 10:52 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020