0 votes
in Python by
explain numpy.full_like() in Python

1 Answer

0 votes
by
numpy.full_like() in Python The full_like() method of Python numpy class returns a full array with the same shape and type as a given array. Syntax

numpy.full_like(a, fill_value, dtype=None, order='K', subok=True)

Parameter shape :This parameter represents the number of rowsorder :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 used to make subclass of ‘a’ or not. It is an optional parameter, and by default, it is Boolean. Return This method returns a new array(ndarray). Example 1

# Python Programming giving an example for

# numpy.full_like() method

importnumpy as numpy

n = numpy.arange(10, dtype = int).reshape(2, 5)

print("Object1 before full_like : \n", n)

# using full_like

print("\nObject2 after full_like : \n", numpy.full_like(n, 10.0))

Output Object1 before full_like :

[[0 1 2 3 4]

[5 6 7 8 9]]

Object2 after full_like :

 [[10 10 10 10 10]

[10 10 10 10 10]]

Related questions

0 votes
asked May 19, 2022 in Python by john ganales
0 votes
asked May 19, 2022 in Python by john ganales
...