 <p>In pure Python you can do this using a dictionary in <code>O(N)</code> time, the only time penalty is going to be the Python loop involved:</p> <pre><code>&gt;&gt;&gt; arr1 = np.array([7.2, 2.5, 3.9]) &gt;&gt;&gt; arr2 = np.array([[7.2, 2.5], [3.9, 7.2]]) &gt;&gt;&gt; indices = dict(np.hstack((arr1[:, None], np.arange(3)[:, None]))) &gt;&gt;&gt; np.fromiter((indices[item] for item in arr2.ravel()), dtype=arr2.dtype).reshape(arr2.shape) array([[ 0., 1.], [ 2., 0.]]) </code></pre>