I want to find the mapping given two arrays A and B, which are permutations of each other. An equivalent function would be
import numpy as np
def perm_map(A, B):
return [np.where(np.array(B) == el)[0][0] for el in A]
print( perm_map(['A', 'B', 'C'], ['B', 'C', 'A']) )
result for this example is [2, 0, 1]
Questions:
- Am I calling it correctly?
- Is there a built-in efficient function for this?