[SciPy-User] structured array question? (slow learner :)
Sat Mar 6 15:08:02 CST 2010
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
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
@ Ryan used ('xb','S5')
@ Christopher used ('xb', '|S10')
I tried ('xb', |S10)
there is also a10 or somthing
numpy.float64() can be used
Is it possible for me to help contribute something like this. As I learn
more about python and numpy I often come across topics that are not very
clear to me, or could benefit from more/different examples. I assume this is
most applicable to the tutorials.
my blog <http://vincentdavis.net> |
On Sat, Mar 6, 2010 at 11:46 AM, Robert Kern <firstname.lastname@example.org> wrote:
> On Sat, Mar 6, 2010 at 11:26, Ryan May <email@example.com> wrote:
> > On Sat, Mar 6, 2010 at 10:44 AM, Vincent Davis <firstname.lastname@example.org
> > wrote:
> >> Ok not sure what I am doing wrong here, In fact I am sure this was
> >> and now I updated python and it doesn't now. I am skeptical that that is
> >> true. My question is what is happening to the strings?
> >> >>> import numpy as np
> >> >>> a = [(1,1),(1,2),(1,3),(2,4),(2,5),(2,6)]
> >> >>> b = [(1,1,'apple', 'pie'),(2,5,'boys','play')]
> >> >>> aa = np.array(a, [('x',int),('y',int)])
> >> >>> bb = np.array(b, [('x',int),('y',int), ('xb',str), ('yb',str)])
> >> >>> bb
> >> array([(1, 1, '', ''), (2, 5, '', '')],
> >> dtype=[('x', '<i8'), ('y', '<i8'), ('xb', '|S0'), ('yb', '|S0')])
> > You need to give it a size for the strings (I've never really understood
> > you need to with structured arrays, but not regular ones).
> np.array() is a complicated function with many codepaths. It can do
> some autodetection for simple dtypes, but it would be difficult to
> write one for structured dtypes, I think.
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User