December 2017
Intermediate to advanced
386 pages
10h 42m
English
To create a 3 x 2 array of doubles, use the following code:
x = np.empty((3,2))
This creates the following array:
array([[ 0., 0.], [ 0., 0.], [ 0., 0.]])
Notice that the array is not actually empty, but filled with arbitrary values. The dtype of the array is, by default, float64. A different type can be specified, as in the following example:
x = np.empty((2,4), dtype=np.int16)
This produces the following array:
array([[0, 0, 0, 0], [1, 0, 0, 0]], dtype=int16)
Read now
Unlock full access