[Numpy-discussion] Dict of lists to numpy recarray

Tom Denniston tom.denniston at alum.dartmouth.org
Fri Aug 24 17:59:53 EDT 2007


Try itertools.izipping the lists and then use numpy.fromiter.

On 8/24/07, Sean Davis <seandavi at gmail.com> wrote:
>
>
> On 8/24/07, Sean Davis <seandavi at gmail.com> wrote:
> > I have a simple question (I assume), but I can't quite get a handle on the
> answer.  I have a dict with each member a list having a long (>5M elements).
>  I would like to convert that into a numpy recarray.  So far, my only
> thought is to loop over the length of the lists and convert to a list of
> tuples--this is SLOW.  What I really need to be able to do is to supply
> columns of data to create a recarray, but I haven't found an example of how
> to do that.
>
> Sorry for the noise.  Found it.
>
> newrecarray =
> numpy.rec.fromarrays([x1,x2,x3],names='x1,x2,x3',formats='f8,i8,i8')
>
> Sean
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>



More information about the NumPy-Discussion mailing list