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')

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()
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises