array from list of lists

Erin Sheldon erin.sheldon at gmail.com
Sun Nov 12 22:17:17 EST 2006


On 11/12/06, Tim Hochberg <tim.hochberg at ieee.org> wrote:
> I haven't been following this too closely, but if you need to transpose
> your data without converting all to one type, I can think of a couple of
> different approaches:
>
>     1.  zip(*yourlist)
>     2. numpy.transpose(numpy.array(yourlist, dtype=object)
>
> I haven't tested them though (particularly the second one), so caveat
> emptor, etc, etc.

Its not that I want to transpose data.

I'm trying to convert the output of a pgdb postgres query into
an array with fields and types corresponding to the columns
I have selected.  The problem is pgdb does not return a list
of tuples as it should according to DB 2.0, but instead
a list of lists.   So numpy.array(lol, dtype=) fails, and so will your
solution #2.   I don't want to copy the data more than once
obviously, so I'm looking for a way to call array() with a lists
of lists.

Erin

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the NumPy-Discussion mailing list