[SciPy-dev] Unexpected behavior getting fields from a structured array

Skipper Seabold jsseabold@gmail....
Fri Nov 6 18:26:29 CST 2009


I just got bit by this and was curious if this is just a limitation of
structured arrays.

import numpy as np
dt = [('var1', 'f'),('var2','f'),('var3','f')]
a = np.array([(1,3.5,0),(1,2.5,1),(3,4,1)], dtype=dt)

array([[ 1. ,  3.5,  0. ],
       [ 1. ,  2.5,  1. ],
       [ 3. ,  4. ,  1. ]], dtype=float32)

I expected this to give me the fields in the order I asked for them,
but I got the fields in the order they occur.  Based on recent
discussions I guess this makes sense, so this might just be something
to look out for?


More information about the Scipy-dev mailing list