i have a list like this:
A=[["a_00",0,0],["a_01",0,1],["a_02",0,2],["a_03",0,3], ["a_10",1,0],["a_11",1,1],["a_12",1,2],["a_13",1,3], ["a_20",2,0],["a_21",2,1],["a_22",2,2],["a_23",2,3], ["a_30",3,0],["a_31",3,1],["a_32",3,2],["a_33",3,3]]
which yields:
In [187]: A
Out[187]:
[['a_00', 0, 0],
['a_01', 0, 1],
['a_02', 0, 2],
['a_03', 0, 3],
['a_10', 1, 0],
['a_11', 1, 1],
['a_12', 1, 2],
['a_13', 1, 3],
['a_20', 2, 0],
['a_21', 2, 1],
['a_22', 2, 2],
['a_23', 2, 3],
['a_30', 3, 0],
['a_31', 3, 1],
['a_32', 3, 2],
['a_33', 3, 3]]
i want to turn in to a matrix like this:
B=[["a_00","a_01","a_02","a_03"], ["a_10","a_11","a_12","a_13"], ["a_20","a_21","a_22","a_23"], ["a_30","a_31","a_32","a_33"]]
yields:
In [188]: B
Out[188]:
[['a_00', 'a_01', 'a_02', 'a_03'],
['a_10', 'a_11', 'a_12', 'a_13'],
['a_20', 'a_21', 'a_22', 'a_23'],
['a_30', 'a_31', 'a_32', 'a_33']]
i wrote this code for my purpose:
import numpy
B=numpy.zeros(7,7)
for item in A:
B[item[1]][item[2]]=item[0]
but i see this error:
IndexError: list index out of range
what should i do?
a_00,a_01etc? String or numeric?