-2

I can initialize a numpy array and reshape it at the time of creation.

test = np.arange(32).reshape(4, 8)

which produces this:

array([[ 0,  1,  2,  3,  4,  5,  6,  7],
   [ 8,  9, 10, 11, 12, 13, 14, 15],
   [16, 17, 18, 19, 20, 21, 22, 23],
   [24, 25, 26, 27, 28, 29, 30, 31]])

... but I'd like to know how to start the sequential numbering at a given point, say at 13 rather than at 0. How is that done in numpy?

I've looked for answers and found something somewhat similar but it seems there would be a numpy command to do this.

hrokr
  • 3,276
  • 3
  • 21
  • 39

1 Answers1

2

arange takes an optional start argument.

start = 13 # Any number works here
np.arange(start, start + 32).reshape(4, 8)

# array([[13, 14, 15, 16, 17, 18, 19, 20],
#        [21, 22, 23, 24, 25, 26, 27, 28],
#        [29, 30, 31, 32, 33, 34, 35, 36],
#        [37, 38, 39, 40, 41, 42, 43, 44]])
acurtis
  • 109
  • 3