numpy shorthand for taking jagged slice
I have an operation that I'm doing commonly which I'm calling a "jagged-slice" because I don't know the real name for it. It's best explained by example: a = np.random.randn(50, 10) entries_of_interest = np.random.randint(10, size = 50) # Vector of 50 indices between 0 and 9 # Now I want the values contained in each row of a at the corresponding index in "entries of interest" jagged_slice_of_a = a[np.arange(a.shape[0]), entries_of_interest] # jagged_slice_of_a is now a vector with 50 elements. Good. Only problem is it's a bit cumbersome to do this a[np.arange(a.shape[0]), entries_of_interest]