Numpy.matrix() is a class that takes array or string as an argument and returns a 2-D array which is called the matrix.
Note: In the official documentation, it is mentioned that matrix() class might be removed in the future. So, instead of this try to use Numpy ndarray. Source: numpy.matrix
data parameter refers to the array or string.
dtype parameter controls the data type od the returned matrix.
Note: Following tutorials are essential to improve your understanding of performing various matrix operations in NumPy:
import numpy as np #Passing string as an argument a = np.matrix('5 10 15; 51 57 68; 32 47 28') print('Matrix creating using string:\n', a) #Passing array as an argument b = np.matrix([[12, 36, 48], [14, 28]]) print('Matrix creation using array:\n', b)
Output of the above program
Matrix creating using string: [[ 5 10 15] [51 57 68] [32 47 28]] Matrix creation using array: [[list([12, 36, 48]) list([14, 28])]]