The numpy.empty_like()
function in Python is used to return a new array with the same shape and data type as the one passed to it.
Note: The
numpy.empty_like()
function does not initialize the returned array.
numpy.empty(array_like)
This function takes the shape and data type of the prototype. It defines or overrides the attributes of the returned array.
The numpy.empty_like()
function returns an array of uninitialized data with the same shape and type as the prototypes passed to it.
import numpy as np# creating a prototype or array_like objecmyarray = ([1,2,3], [4,5,6])# using the numpy.empty() functionnewarray = np.empty_like(myarray)print(newarray)
numpy
module.myarray
.numpy.empty()
function on the variable myarray
and the result is assigned to another variable newarray
.newarray
.