Having the following arrays (I understand the first one is call a matrix)
ids = np.array([['Peter Parker','Spiderman'],['Ben Reilly','Scarlet Spider'],['Norman Osborn','Green Goblin'],['Bruce Banner','Hulk']])
And
heroes=np.array(['Spiderman','Scarlet Spider','Capitan America','Iron Man'])
I'm able to find the "heroes" values that matches rows in "ids" but I can only print the matches like
print(ids[np.where(ids==(np.row_stack(heroes)))])
Which outputs
['Spiderman' 'Scarlet Spider']
Is it (and how) possible to print them like ?
['Peter Parker' 'Ben Reilly']
note
This is a given exercise, I don't expect other requirements like having the qty of elements on the heroes
array diff from the # of rows in the ids
array (this would it break my current code due the use of row_stack
).
But I noticed that my where
would not find duplicated values on the ids
array (like if I have 2 "Spiderman" with diff name and both names appears in the heroes
array), feel free to extend to this but main question is what I just wrote with no other given restrictions.