What is Python’s Numpy function zeros()?
Published:
np.zeros() generate the array of given shape and type, with zeros being its elements.
Syntax: numpy.zeros(shape, d_type = None, order = 'C')
where, shape
defines the dimension of array, it can be integer or sequence. $[2,3]$ for generating the $2 \times 3$ matrix.
data_type
defines whether it is integer or float (default).
order
defines whether to store in row-major (default) or coloumn major.
Example:
import numpy as np
np.zeros([2,3], dtype='int')
Output:
Example:
import numpy as np
np.zeros(2, dtype='int')
Output: