>>> a = np.array([[1,2,3], [3,2,4]]) >>> my_dict = {1:23, 2:34, 3:36, 4:45} >>> np.vectorize(my_dict.get)(a) array([[23, 34, 36], [36, 34, 45]])