- zeros
Returns a new array of given shape and type, filled with zeros.
np.zeros((5,), dtype=int)
>>>
array([0, 0, 0, 0, 0])
s = (2,2)
np.zeros(s)
>>>
array([[ 0., 0.],
[ 0., 0.]])
- zeros_like
Return an array of zeros with the same shape and type as a given array.
x = np.arange(6)
x = x.reshape((2, 3))
x
>>>
array([[0, 1, 2],
[3, 4, 5]])
np.zeros_like(x)
array([[0, 0, 0],
[0, 0, 0]])
y = np.arange(3, dtype=float)
y
>>>
array([0., 1., 2.])
np.zeros_like(y)
>>>
array([0., 0., 0.])
'Analyze Data > Python Libraries' 카테고리의 다른 글
numpy-pad (0) | 2023.12.26 |
---|---|
numpy-ogrid VS mgrid (0) | 2023.11.17 |
EasyDict (0) | 2023.10.18 |
numpy-concatenate (0) | 2023.06.07 |
numpy-identity (0) | 2023.06.02 |