numpy.empty_like() in Python

The empty_like() method of Python numpy class returns a new array with the same shape and type as the specified array.

Syntax

Parameters

The numpy. empty_like() method consists of four parameters, which are as follows:

prototype : The shape and data-type of prototype define  the attributes of the returned array.

order : The order parameter can be either C_contiguous or F_contiguous

dtype : It is an optional parameter. It depicts the data type of returned array, and by default, it is a float.

subok : It is an optional Boolean argument that is used to make a subclass of type ‘a’ or not. By default, it is true.

Return Value

The numpy.empty_like() method returns an array with the same shape and type as the given array.

Example 1

Output

Pin It on Pinterest

Share This