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

Ryan May rmay31@gmail....
Sun Mar 7 08:58:24 CST 2010


On Sat, Mar 6, 2010 at 3:08 PM, Vincent Davis <vincent@vincentdavis.net>wrote:

> Again I am new to this but I spent 2hr on this and looked at the
> documentation an tutorials. To be fare there are not a lot of examples using
> strings.
> I would suggest that there are two many ways to specify dtype. At least
> that is my impression.
> I would find a nice table that list all with the different way they are
> used.
>
> for example
> @ Ryan used ('xb','S5')
> @ Christopher used  ('xb', '|S10')
>

These are both specifying strings.  'S5' is just specifying a string length
of 5 while '|S10' is specifying a string length of 10.  The '|' is optional
and specifies that the system-native endianness should be used to control
the byte ordering. So these are both the exact same way.


> I tried ('xb', |S10)
>

There's no way this actually ran without quotes.


> there is also a10 or somthing
>

'a' is the same as using 'S' above.


> numpy.float64() can be used
>

That's for floating point types, not strings. A lot of the complexity from
strings is that, unlike numeric types, there's no minium/typical sizes to
assume for strings. This, combined with the fact that all items within a
numpy array have to have the same size, makes string handling complex.
(This implies that in memory, (1,1,'apple', 'pie') and (2,5,'boys','play')
will occupy the same amount of memory.)

Did you look at this:

http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100307/df4e5940/attachment.html 


More information about the SciPy-User mailing list