Numpy.zeros_like() in Python

The zeros_like() method of Python numpy class returna an array of zeros with the same shape and type as that of specified array.

Syntax

Parameter

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

arrray : This parameter represents an array_like input

subok  :It true is invoked then it represents  newly created array will be sub-class of array else it represents  a base-class array

order  :The order parameter can be either C_contiguous or F_contiguous. C order means that operating row-rise on the array will be slightly quicker

FORTRAN-contiguous order in memory (the first index varies the fastest). F order means that column-wise operations will be faster.

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

Return

This method returns an array of zeros having given shape, order and datatype.

Example 1

Output

Original array :

Matrix :

Matrix :

Pin It on Pinterest

Share This