June 2015
Beginner
348 pages
8h 44m
English
Let's demonstrate how the full() and full_like() functions work. If you are not in a Python shell already, type the following:
$ python >>> import numpy as np
full() function filled with the number 42 as follows:>>> np.full((1, 2), 42) array([[ 42., 42.]])
As you can deduce from the output, the array elements are floating-point numbers, which is the default data type for NumPy arrays. Specify an integer data type as follows:
>>> np.full((1, 2), 42, dtype=np.int) array([[42, 42]])
full_like() function looks at the metadata of an input array and uses that information to create a new array, filled with a specified ...Read now
Unlock full access