Why does this not work?

dat=[[1,2,3],[4,5,6]]
col=[('a','f4'),('b','f4'),('c','f4')]
arr=numpy.array(dat,dtype=col)

Traceback (most recent call last):
 File "<pyshell#91>", line 1, in <module>
   arr=numpy.array(dat,dtype=col)
TypeError: expected a readable buffer object


But this does:

dat=[(1,2,3),(4,5,6)]
arr=numpy.array(dat,dtype=col)
arr
array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)], dtype=[('a', '<f4'), ('b', '<f4'), ('c', '<f4')])


The only difference that the object is a list of tuples now?

Thanks for clarification,
Alex van der Spek


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to