[Numpy-discussion] printing structured arrays

Bruce Schultz bruce.schultz at gmail.com
Fri Mar 5 09:00:02 EST 2010


Hi,

I've just started playing with numpy and have noticed that when printing
a structured array that the output is not nicely formatted. Is there a
way to make the formatting look the same as it does for an unstructured
array?

Here an example of what I mean:

data = [ (1, 2), (3, 4.1) ]
dtype = [('x', float), ('y', float)]
print '### ndarray'
a = numpy.array(data)
print a
print '### structured array'
a = numpy.array(data, dtype=dtype)
print a

Output is:
### ndarray
[[ 1.   2. ]
 [ 3.   4.1]]
### structured array
[(1.0, 2.0) (3.0, 4.0999999999999996)]


Thanks
Bruce

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100306/11d6756f/attachment.html>


More information about the NumPy-Discussion mailing list