1

I am trying to achieve the indexes in the following manner:

[1,3,5,7,9,11...],
[2,4,6,8,10,12,...],
[3,5,7,9,11,13...],
[4,6,8,10,12,14,..],

So far I've achieved the format as:

[1,2,3,4,5,...],
2,3,4,5,6,7...]
3,4,5,6,7,8...],

using the CODE LINE

indexer = np.arange(3)[None,:] + np.arange(8)[:,None]

I am not sure how to achieve desired results.

Kindly help me with this!

Thanks

1 Answers1

0

You can define a step size for np.arange in the following way np.arange(start, stop, step):

>>> np.arange(1, 12, 2)[None,:] + np.arange(4)[:,None]
array([[ 1,  3,  5,  7,  9, 11],
       [ 2,  4,  6,  8, 10, 12],
       [ 3,  5,  7,  9, 11, 13],
       [ 4,  6,  8, 10, 12, 14]])
a_guest
  • 34,165
  • 12
  • 64
  • 118