What is numpy.matrix() in Python
A matrix in Numpy returns a matrix from a string of data or array-like object. The matrix obtained is a specialized 2D array.
Syntax: numpy.matrix(object, dtype = None) :
Creating a NumPy matrix using the .matrix() function.
Python3
import numpy as np mat = np.matrix([[ 1 , 2 , 3 ], [ 5 , 6 , 7 ], [ 4 , 6 , 8 ]]) print ( "Matrix is : \n" , mat) print ( type (mat)) |
Output:
Matrix is : [[1 2 3] [5 6 7] [4 6 8]] <class 'numpy.matrix'>
Difference between Numpy array and Numpy matrix
While working with Python many times we come across the question that what exactly is the difference between a numpy array and numpy matrix, in this article we are going to read about the same.
Contact Us