In Python, the ma.empty()
function is used to create a new array of a given shape and type without the entries being initialized and random elements.
ma.empty(shape, dtype=float, order='C', *, like=None)
This function takes the following parameter values:
shape
: This is the shape of the resulting array.dtype
: This is the data type of the resulting array—for example, numpy.int8
. The default value is numpy.float64
. This is optional.like
: This is a reference to an object that allows us to create new arrays which are not NumPy arrays.import numpy as np# creating a shape for the arraymyshape = (2,3)# implementing the ma.empty() functionnewarray = np.empty(myshape, dtype=float, order="F" )# printing the arrayprint(newarray)
numpy
module.shape
for the resulting array.ma.empty()
function. The result is assigned to a variable newarray
.newarray
.