How to Create Zero Array in Numpy

To create zero array is very easy in numpy, you shoud know two things:

1. what’s demension of this zero array

2. use numpy.zeros() function

For example:

1. create 1 demension zero array with 5 elements

>>> import numpy as np
>>> x = np.zeros(5)
>>> x
array([ 0., 0., 0., 0., 0.])

2. create 2 demension zero array with 2*2 elements

>>> y = np.zeros((2,2))
>>> y
array([[ 0., 0.],
 [ 0., 0.]])

3. create 3 demension zero array with 1*2*3 elements

>>> z = np.zeros((1,2,3))
>>> z
array([[[ 0., 0., 0.],
 [ 0., 0., 0.]]])

,