[SciPy-User] structured array question? (slow learner :)

Christopher Barker Chris.Barker@noaa....
Sat Mar 6 11:25:14 CST 2010

Vincent Davis wrote:
> Ok not sure what I am doing wrong here, In fact I am sure this was 
> working and now I updated python and it doesn't now.

I'm not sure if anything has changed, but:

> I am skeptical that 
> that is true. My question is what is happening to the strings?

strings in a structured array need to have a length specified. They 
default to 0:
>       dtype=[('x', '<i8'), ('y', '<i8'), ('xb', '|S0'), ('yb', '|S0')])

this works:
In [9]: bb = np.array(b, dtype=[('x', np.int),('y', np.int), 
('xb','S10'), ('yb', 'S10')])

In [10]: bb
array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')],
       dtype=[('x', '<i4'), ('y', '<i4'), ('xb', '|S10'), ('yb', '|S10')])


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception


More information about the SciPy-User mailing list