I want to convert this numpy array into a 3 by 3 matrix
array([[3,4,5],
[5,6,7],
[2,3,4]])
How to do this in python ?
I want to convert this numpy array into a 3 by 3 matrix
array([[3,4,5],
[5,6,7],
[2,3,4]])
How to do this in python ?
It's already a matrix. In numpy you can read data as follow:
>>> a
array([[3, 4, 5],
[5, 6, 7],
[2, 3, 4]])
>>> a[0] # first line
array([3, 4, 5])
>>> a[1] # second line
array([5, 6, 7])
>>> a[0,1] # value of second col on first line
4
It is already a 3x3 numpy array.
>>> import numpy as np
>>> array = np.array([[3, 4, 5],
[5, 6, 7],
[2, 3, 4]])
>>> print(array.shape)
(3, 3)