Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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 ?
numpy.matrix()
np.matrix
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
Add a comment
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)
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
numpy.matrix()?np.matrixis evil.