[Tutor] list to numpy record array

Vincent Davis vincent at vincentdavis.net
Tue Feb 23 18:44:28 CET 2010


@Kent
All I know about RecordArrays is from reading this page:
http://www.scipy.org/RecordArrays
but it looks like you have done the right thing and created a
RecordArray. What is wrong with this result?

The number are completely different, or I have no idea how to read it.
Here are the first row of each
normal array  ['  0', '  0', '234.0', '24.0', ' 25']
Record array  [(3153952, 0, 0.0, 0.0, 0)

*Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>


On Tue, Feb 23, 2010 at 6:30 AM, Kent Johnson <kent37 at tds.net> wrote:

> On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis
> <vincent at vincentdavis.net> wrote:
> >
> > I must be missing something simple. I have a list of lists data = "[['
>  0', '  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', '
> 25'],......" and what to make a record array from it but it gets screwed up
> or I don't get it, maybe both.
> >
> > bdata = numpy.array(data, [('x', int),('y',
> int),('mean',float),('stdv',float),('npixcels',int)])
> > >>> bdata
> > array([[(3153952, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
> ...
> >         (3486240, 0, 0.0, 0.0, 0)]],
> >
> >       dtype=[('x', '<i8'), ('y', '<i8'), ('mean', '<f8'), ('stdv',
> '<f8'), ('npixcels', '<i8')])
>
> All I know about RecordArrays is from reading this page:
> http://www.scipy.org/RecordArrays
> but it looks like you have done the right thing and created a
> RecordArray. What is wrong with this result?
>
> Kent
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100223/e90b3a6e/attachment.html>


More information about the Tutor mailing list