[SciPy-User] structured array question? (slow learner :)
Christopher Barker
Chris.Barker at noaa.gov
Sat Mar 6 12:25:14 EST 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
Out[10]:
array([(1, 1, 'apple', 'pie'), (2, 5, 'boys', 'play')],
dtype=[('x', '<i4'), ('y', '<i4'), ('xb', '|S10'), ('yb', '|S10')])
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
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
Chris.Barker at noaa.gov
More information about the SciPy-User
mailing list