I want to extract a range of indices contained in the 'ranges' list from the 'nums' array.
For example:
ranges=np.arange(10, 100, 10).tolist()
#[10, 20, 30, 40, 50, 60, 70, 80, 90]
nums=np.arange(10, 1000, 5.5)
Here, I want to extract indices 10 to 20, and then 20 to 30 and so on until indices 80 to 90 specified in the 'ranges' list from the 'nums' array. I'm not sure how to cycle between every two numbers through the 'ranges' list.
If I just had to extract 2-3 ranges of indices, I would just hard code the indices and slice-
idx1 = nums[10:21]
idx2 = nums[20:31]
idx3 = nums[30:41]
But this gets tedious to do for various combinations of ranges, especially in my original dataset with almost 100 ranges of indices to extract.
Appreciate any help on this.
nums[10:].reshape(-1,10).