Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy: full() function

full() function

The full() function return a new array of given shape and type, filled with fill_value.

Syntax:

numpy.full(shape, fill_value, dtype=None, order='C')
NumPy array: full() function

Version: 1.15.0

Parameter:

Name Description Required /
Optional
shape Shape of the new array, e.g., (2, 3) or 2. Required
fill_value Fill value. Required
dtype The desired data-type for the array The default, None, means np.array(fill_value).dtype. optional
order Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory optional

Return value:

[ndarray] Array of fill_value with the given shape, dtype, and order.

Example: numpy.zeros() function

>>> import numpy as np
>>> np.full((3, 3), np.inf)
array([[ inf,  inf,  inf],
       [ inf,  inf,  inf],
       [ inf,  inf,  inf]])
>>> np.full((3, 3), 10.1)
array([[ 10.1,  10.1,  10.1],
       [ 10.1,  10.1,  10.1],
       [ 10.1,  10.1,  10.1]])

Pictorial Presentation:

NumPy array: full() function

Example: numpy.full() function where data type is int

>>> import numpy as np
>>> np.full((3,3), 55, dtype=int)
array([[55, 55, 55],
       [55, 55, 55],
       [55, 55, 55]])

Pictorial Presentation:

NumPy array: full() function

Python - NumPy Code Editor:

Previous: zeros_like()
Next: full_like()