[Numpy-discussion] array of tuples
Travis N. Vaught
travis at enthought.com
Tue Jun 6 14:05:43 EDT 2006
I'd like to construct an array of tuples and I'm not sure how (without
looping). Is there a quick way to do this with dtype?
I've tried:
>>> import numpy
>>> x = [(1,2,3),(4,5,6)]
>>> numpy.array(x)
array([[1, 2, 3],
[4, 5, 6]])
>>> numpy.array(x, dtype='p')
array([[1, 2, 3],
[4, 5, 6]])
>>> numpy.array(x, dtype='O')
array([[1, 2, 3],
[4, 5, 6]], dtype=object)
Thanks,
Travis
More information about the NumPy-Discussion
mailing list