I want to extract very specific elements from an array to create various ranges.
For example,
ranges = np.arange(0, 525, 25)
#array([ 0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500])
I want to create ranges that output as this-
0 50
75 125
150 200
225 275
300 350
375 425
450 500
I know if I want to extract every number into a range, I can write something like this-
for start, end in zip(ranges[:-1], ranges[1:]):
print(start, end)
Which would give the result-
0 50
25 75
50 100
75 125
100 150
125 175
150 200
175 225
200 250
225 275
250 300
275 325
300 350
325 375
350 400
375 425
400 450
425 475
However, I'm not sure how to extract every other element from the array.
ranges[np.arange(len(ranges))%3!=1].reshape(-1,2)?50, one with length25. What's the logics here?np.stack((np.arange(0, 500, 75), np.arange(50, 550, 75)), axis=1)seems like what you want?ranges = np.arange(0, 525, 25); ranges.reshape(-1,3)[:,[0,2]]?