The numpy.full()
function is used to return a new array of a given shape and data type filled with fill_value
.
numpy.full(shape, fill_value, dtype=None, like=None)
The numpy.full()
function takes the following parameter values:
shape
: This represents the shape of the desired array.fill_value
: This represents the fill value.dtype
: This represents the data type of the desired array. This is an optional parameter.like
: This represents the prototype or the array_like
object.The numpy.full()
function returns an array of fill_value
shape, data type, and order.
import numpy as np# implementing the numpy.full() functionmyarray = np.full((2, 2), 5)print(myarray)
numpy
module.numpy.full()
function on an array that has 2 arrays and 2 elements to change all the elements to 5
. The output is assigned to a variable myarray()
.myarray
.