import numpy as np
a = np.array(['john', 'bill', 'greg', 'bill', 'bill', 'greg', 'bill'])
b = np.array(['john', 'bill', 'greg'])
my_dict = dict(zip(b, list(range(len(b)))))
result = np.vectorize(my_dict.get)(a)
Numpy Indexing of 2 Arrays