First page Back Continue Last page Overview Graphics

Creating Evenly Spaced Arrays

arange([start,] stop[, step,], dtype=None)

Return evenly spaced values within a given interval.

Values are generated within the half-open interval „[start, stop)“

(in other words, the interval including „start“ but excluding „stop“).

>>> np.arange(10)

array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

>>>

>>> np.arange(3,10)

array([3, 4, 5, 6, 7, 8, 9])

>>>

>>> np.arange(3,10,2)

array([3, 5, 7, 9])

It's possible to use float values as well:

>>> np.arange(1.1, 10.4, 0.7)

array([ 1.1, 1.8, 2.5, 3.2, 3.9, 4.6, 5.3, 6. , 6.7,

7.4, 8.1, 8.8, 9.5, 10.2])