Extracting an arbitrary element from each row of a np.array
The best way to do this is how @GarethRees suggested in the comments:

&gt;&gt;&gt; arr[np.arange(4), keys]
array([1, 3, 7, 11])


There is another (not as good) solution that is a better alternative to using arr[i, keys[i]] for i in range(len(keys)).  Whenever you want both the index and the item from some iterable, you should generally use the enumerate function:

&gt;&gt;&gt; np.array([arr[i, item] for i, item in enumerate(keys)])
array([1, 3, 7, 11])