I have a matrix like this and want to convert it to array for processing. How to do it
[[25 3 0 1 0 2 1]
[ 1 21 0 0 0 0 0]
[ 0 3 18 0 0 0 0]
[ 1 0 0 35 2 0 0]
[ 0 0 0 4 27 2 0]
[ 0 0 0 0 1 27 0]
[ 1 1 0 0 0 0 34]]
I understand that it should be of the form
[[25, 3, 0, 1, 0, 2, 1],
[ 1, 21, 0, 0, 0, 0, 0],
[ 0, 3, 18, 0, 0, 0, 0],
[ 1, 0, 0, 35, 2, 0, 0],
[ 0, 0, 0, 4, 27, 2, 0],
[ 0, 0, 0, 0, 1, 27, 0],
[ 1, 1, 0, 0, 0, 0, 34]]
Usually what i am doing is convert my array to the above form manually and calling
class = np.array([[28, 3, 0, 0, 5, 2, 1],
[ 6, 25 , 0, 2, 2, 8, 0],
[ 0 , 1 ,51 , 0, 0, 0, 0],
[ 5 , 2 , 0 ,25, 12, 2, 2],
[ 1 , 0 , 0, 2, 40, 6, 0],
[ 0 , 0 , 0 ,0, 1, 48, 0],
[ 2 , 1, 0 ,0 , 1, 1, 51]])
I am not sure what format you have when importing the matrix, here a solution for a string based matrix.
or in one line: