How do you create a 1 x n array in NumPy following an incrementing pattern?
For example:
[0, 5, 10, 15, ... (n-1)*5]
np.arange is the correct answer (as pointed out in the comments). For completeness, here's a list of simple 1-liners that will produce the desired array:
np.arange(n)*5np.arange(0, n*5, 5)np.linspace(0, (n-1)*5, n, dtype=int)np.array(range(0, n*5, 5))For example, if n=7 then all of the above will produce the array:
[ 0 5 10 15 20 25 30]
np.arange(n) * 5where youimport numpy as npfirstnp.arange(0, N+1, 5)[0, 5, 10, 15, ... (n-1)*5]? What you currently have doesn't make complete sense.