0 votes
in Python by

explain Numpy.asmatrix() in Python with Example

1 Answer

0 votes
by

Numpy.asmatrix() in Python The asmatrix() function returns the specified input as a matrix. It does not make a copy if the input is already a matrix or an ndarray. Syntax

numpy.asmatrix(data, dtype=None)

Parameter data  :This parameter represents thearray-like input data dtype :It depicts the data type of returned array  Return This function interprets the input as a matrix.  Example 1

# Python Programming giving an example for 
# numpy.asanyarray() function
importnumpy as numpy
# array-like input
mat_arr = numpy.matrix([[5, 6, 7], [4, 6]])
print("Via array-like input : \n", mat_arr)
asmat_arr = numpy.asmatrix(mat_arr)
mat_arr[0, 1] = 10
print("\nAsymmetric matrix : \n", asmat_arr)

Output

Via array-like input :
 [[[5, 6, 7] [4, 6]]]
Asymmetric matrix :
 [[[5, 6, 7] 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
...