import numpy as np a = np.matrix([11,25,40], [5,34,98], [32,12,60])
PS: Also reviewed the similar question asked but the array was not complete there. Please guide what to do here?enter image description here
CodePudding user response:
You have to wrap the lists into a main list. the matrix
constructor accepts a single iterable:
a = np.matrix([[11,25,40], [5,34,98], [32,12,60]])
output:
matrix([[11, 25, 40],
[ 5, 34, 98],
[32, 12, 60]])
NB. note that the use of matrix
is no longer recommended (see docs, you should use numpy.array
instead