Numpy Dynamic Slicing Per Row
How do I dynamically slice each row given a starting and ending index without using a for loop. I can do it with loop listed below, but it is way too slow for something where the x.shape[0] > 1 mill x= np.arange(0,100) x = x.reshape(20,5) s_idx = np.random.randint(0,3,x.shape[0]) e_idx = np.random.randint(3,6,x.shape[0]) print(s_idx) >>> array([2, 1, 2, ..., 1, 0, 2]) print(e_idx) >>> array([3, 4, 5, ..., 3, 3, 3]) print(x) >>> array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], ..., [85, 86, 87, 88, 89], [90, 91, 92, 93, 94], [95, 96, 97, 98, 99]]) x_indexed = [] for idx,value in