NumPy array creation: 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')`

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:

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:

Python - NumPy Code Editor:

Previous: zeros_like()
Next: full_like()

﻿