numpy.empty(shape, dtype=float, order='C')
Return array without initializing entries.
shape | Int, or sequence ( 2,3), shape of the output array |
dtype | data-type( Optional ), Data Type of returned array. |
order | {'C','F'} Optional, how the output is to be stored. C- style or Fortan style |
Using shape
import numpy as np
ar=np.empty((1,3))
print(ar)
Output
[[5.e-324 5.e-324 5.e-324]]
Let us use different value for shape
ar=np.empty((4,2))
print(ar)
Output
[[3.02200272e-316 1.58101007e-322]
[2.07955588e-312 1.16151774e-046]
[4.81836453e-038 1.33694116e+165]
[1.93417383e+184 1.33511316e-306]]
ar=np.empty((4,1))
print(ar)
Output
[[5.e-324]
[5.e-324]
[5.e-324]
[0.e+000]]
dtype
We will try to return string dtype
import numpy as np
ar=np.empty(4,dtype=str)
print(ar) # ['' '' '' '']
Output
['' '' '' '']
dtype=float
ar=np.empty(4,dtype=float)
print(ar)
Output
[5.e-324 5.e-324 5.e-324 0.e+000]
dtype=int
ar=np.empty(4,dtype=int)
print(ar) # [1 1 1 0]
Output
[1 1 1 0]
ar=np.empty(4,dtype=np.int64)
print(ar) # [1 1 1 0]
Output
[1 1 1 0]
empty_like()
«Numpy
eye()
bincount()
arange()
linspace()
← Subscribe to our YouTube Channel here