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

Keith Goodman kwgoodman@gmail....
Thu Feb 4 17:46:44 CST 2010


On Thu, Feb 4, 2010 at 2:26 PM, Vishal Rana <ranavishal@gmail.com> 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': 260.0},
> 'name': 'Fred', 'age': 15, 'weight': 145.0}]

It looks like a two-body problem, so it should be solvable.


More information about the NumPy-Discussion mailing list