With brute-force NumPy broadcasting -
idx = np.nonzero(transdict.keys() == abc_array[:,None])[1]
out = np.asarray(transdict.values())[idx]
With np.searchsorted based searching and indexing -
sort_idx = np.argsort(transdict.keys())
idx = np.searchsorted(transdict.keys(),abc_array,sorter = sort_idx)
out = np.asarray(transdict.values())[sort_idx][idx]
Sample run -
In [1]: abc_array = np.array(['B', 'D', 'A', 'B', 'D', 'A', 'C'])
...: transdict = {'A': 'Adelaide', 'B': 'Bombay', 'C': 'Cologne', 'D': 'Delhi'}
...:
In [2]: idx = np.nonzero(transdict.keys() == abc_array[:,None])[1]
...: out = np.asarray(transdict.values())[idx]
...:
In [3]: out
Out[3]:
array(['Bombay', 'Delhi', 'Adelaide', 'Bombay', 'Delhi', 'Adelaide',
'Cologne'],
dtype='|S8')
In [4]: sort_idx = np.argsort(transdict.keys())
...: idx = np.searchsorted(transdict.keys(),abc_array,sorter = sort_idx)
...: out = np.asarray(transdict.values())[sort_idx][idx]
...:
In [5]: out
Out[5]:
array(['Bombay', 'Delhi', 'Adelaide', 'Bombay', 'Delhi', 'Adelaide',
'Cologne'],
dtype='|S8')