This method is used to create a specified dimension (shape)、 data type (dtype) Uninitialized array of .
numpy.empty(shape, dtype=float, order='C')
shape
: A tuple representing an array dimension dtype
: data type order
: Yes “C” and “F” Two options
Create an empty array ( Subsequently, users are required to manually set all values in the array ):
empty() Methods and zeros() The method is different , The array value will not be set to zero , So it could be a little faster . On the other hand , It requires the user to manually set all values in the array , And use it with caution .
Create the specified dimension , With 0 New array filled .
numpy.zeros(shape, dtype=float, order='C')
shape
: A tuple representing an array dimension dtype
: data type order
: Yes “C” and “F” Two options Be careful : The default is float Type of
Create the specified dimension , With 1 New array filled .
numpy.ones(shape, dtype=float, order='C')
shape
: A tuple representing an array dimension dtype
: data type order
: Yes “C” and “F” Two options Returns a new array of the given dimension and type , fill fill_value.
numpy.full(shape, fill_value, dtype=None, order='C')
shape
: Returns the dimension of the array fill_value
: Fill value dtype
: Returns the data type of the array , The default value is None finger :np.array(fill_value).dtypeorder
: The order of storage elements in computer memory , Only support ‘C’( Press the line )、‘F’( By column ), Default ‘C’
Reference resources :【Python library 】NumPy Detailed tutorial (1):NumPy Array