Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Vishal Rana
Warren, thanks for the information. Vishal Charles de Gaulle - "The better I get to know men, the more I find myself loving dogs." On Thu, Feb 4, 2010 at 4:10

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Vishal Rana
Thanks Robert :) Vishal Rana Samuel Goldwyn - "I don't think anyone should write their autobiography until after they're dead." On Thu, Feb 4, 2010 at 4:04 PM, Robert Kern wrote: > On Thu, Feb 4, 2010 at 16:26, Vishal Rana wrote:

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Warren Weckesser
Vishal, Robert's code does the trick, but--in case you are new to numpy record arrays-I thought I'd point out that the array itself already acts like a list of dictionaries: In [6]: import numpy as np In [7]: dt = np.dtype([('name', 'S30'),('age',int),('weight',float)]) In [8]: r = np.array([

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Robert Kern
On Thu, Feb 4, 2010 at 16:26, Vishal Rana wrote: > How do I convert the numpy record array below: > recs = [('Bill', 31, 260.0), ('Fred', 15, 145.0)] > r = rec.fromrecords(recs, names='name, age, weight', formats='S30, i2, f4') > to a list of dictionary like: > [{'name': 'Bill', 'age': 31, 'weight

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Keith Goodman
On Thu, Feb 4, 2010 at 3:46 PM, Keith Goodman wrote: > On Thu, Feb 4, 2010 at 2:26 PM, Vishal Rana wrote: >> How do I convert the numpy record array below: >> recs = [('Bill', 31, 260.0), ('Fred', 15, 145.0)] >> r = rec.fromrecords(recs, names='name, age, weight', formats='S30, i2, f4') >> to a l

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Keith Goodman
On Thu, Feb 4, 2010 at 2:26 PM, Vishal Rana wrote: > How do I convert the numpy record array below: > recs = [('Bill', 31, 260.0), ('Fred', 15, 145.0)] > r = rec.fromrecords(recs, names='name, age, weight', formats='S30, i2, f4') > to a list of dictionary like: > [{'name': 'Bill', 'age': 31, 'weig

[Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Vishal Rana
How do I convert the numpy record array below: recs = [('Bill', 31, 260.0), ('Fred', 15, 145.0)] r = rec.fromrecords(recs, names='name, age, weight', formats='S30, i2, f4') to a list of dictionary like: [{'name': 'Bill', 'age': 31, 'weight': 260.0}, 'name': 'Fred', 'age': 15, 'weight': 145.0}] _