May 2019
Beginner
528 pages
29h 51m
English
arrays with Specific ValuesNumPy provides functions zeros, ones and full for creating arrays containing 0s, 1s or a specified value, respectively. By default, zeros and ones create arrays containing float64 values. We’ll show how to customize the element type momentarily. The first argument to these functions must be an integer or a tuple of integers specifying the desired dimensions. For an integer, each function returns a one-dimensional array with the specified number of elements:
In [1]: import numpy as npIn [2]: np.zeros(5)Out[2]: array([ 0., 0., 0., 0., 0.])
For a tuple of integers, these functions return a multidimensional array with the specified dimensions. You can specify the array’s element type with the zeros and ...
Read now
Unlock full access