📅  最后修改于: 2023-12-03 15:17:59.483000             🧑  作者: Mango
Numpy.zeros() function returns a new array of given shape and type and fills it with zeros.
numpy.zeros(shape, dtype=float, order='C')
float
.'C'
, row-major order.import numpy as np
# Creating an array with shape (3,4) and data type int
a = np.zeros((3,4), dtype=int)
print(a)
# Output
# [[0 0 0 0]
# [0 0 0 0]
# [0 0 0 0]]
In this example, we create a new array of shape (3,4)
and data type int
using np.zeros()
function. The returned array is filled with zeros.
np.zeros()
is a useful function for creating new arrays filled with zeros. It is particularly useful in situations where we need to create an array of specific shape and fill it with zeros before populating it with other values.