What about: idx_by_name = dict(enumerate(d.dtype.names)) Then I can look up the index of the columns I want before the loop, and then access by the index during the loop. - W On Wed, Jul 21, 2010 at 4:29 PM, Pierre GM <pgmdevlist@gmail.com> wrote:
On Jul 21, 2010, at 4:22 PM, wheres pythonmonks wrote:
However: is there an automatic way to convert a named index to a position?
What about looping over tuples of my recarray:
for t in d: date = t['Date'] ....
Why don't you use zip ?
for (date, t) in (d['Date'], d)
That way, you save repetitive calls to __getitem__....
Should I create a map from dtype.names(), and use that to look up the index based on the name in advance? (if I really really want to factorize out the lookup of 'Date']
Meh. I have a bad feeling about it that it won't be really performant.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion