I have the following two arrays:
array1 = numpy.asarray(['x', 'a', 'y', 'b', 'c'], dtype=str)
array2 = numpy.asarray(['c','y','a'], dtype=str)
as a result I need to have an array that contains the indexes from array1 of the elements that are present in array2. Furthermore, the resulting array has to have the order of the labels from array2 like this:
In [1]: result_nd
Out[2]: array([4, 2, 1])
What would be the most concise and computationally effective way of achieving this (the array1 can have millions of elements)?