In Python, the numpy.empty()
function is used to return new array of a given shape and type. It has random values and uninitialized entries.
numpy.empty(shape, dtype=float, order='C')
This function takes the following parameter values:
shape
: This represents the shape of the empty array.dtype
: This represents the data type. The default type is numpy.float64
.order
: This is used to store multi-dimensional data in row-major (C
-style) or column-major (F
-style) order in memory. The default order is C
. This is optional.This function returns an array of uninitialized data of the given shape
, dtype
and order
. The objects of the array are initialized to none.
import numpy as np# using the numpy.empty() function on a 2D arraymyarray = np.empty([2, 2], dtype = int )print(myarray)
numpy
module.numpy.empty()
function to set the array shape, data type, and order as 2D
, int
, C
, respectively. We assign the output to a variable myarray
.myarray
.