numpy.zeros(shape,dtype=float,order='C')¶Return a new array of given shape and type, filled with zeros.
| Parameters: | shape : int or sequence of ints
dtype : data-type, optional
order : {‘C’, ‘F’}, optional
|
|---|---|
| Returns: | out : ndarray
|
See also
zeros_likeones_likeempty_likeonesemptyExamples
>>>np.zeros(5)array([ 0., 0., 0., 0., 0.])
>>>np.zeros((5,),dtype=np.int)array([0, 0, 0, 0, 0])
>>>np.zeros((2,1))array([[ 0.], [ 0.]])
>>>s=(2,2)>>>np.zeros(s)array([[ 0., 0.], [ 0., 0.]])
>>>np.zeros((2,),dtype=[('x','i4'),('y','i4')])# custom dtypearray([(0, 0), (0, 0)], dtype=[('x', '<i4'), ('y', '<i4')])