NumPy (continued)
Key NumPy Functions
np.arange()
np.arange()### 3 Arguments
np.arange(beginning, end, space_between)
### 2 Arguments
### Assumes the space_between is 1.
np.arange(beginning, end)
### 1 Argument
### Assumes the beginning is 0 and the space_between is 1.
np.arange(end)>>> np.arange(0, 10, 1)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
### Notice that 10 is not included in our range.
>>> np.arange(3, 45, 2)
array([ 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35,
37, 39, 41, 43])
### The end value is never included.
>>> np.arange(0, 15, 5)
array([ 0, 5, 10])
>>> np.arange(0, 16, 5)
array([ 0, 5, 10, 15])np.count_nonzero()
np.count_nonzero()np.random.choice()
np.random.choice()Computations / Array Arithmetic
Summary
Last updated
Was this helpful?