>
> Message: 8
> Date: Mon, 22 Sep 2008 19:28:50 -0400
> From: Pierre GM <[EMAIL PROTECTED]>
> Subject: Re: [Numpy-discussion] array with named columns (or record
> arrays with homogenous types)
> To: Discussion of Numerical Python <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Monday 22 September 2008 19:25:16 Tony S Yu wrote:
>
>>>>> import numpy as np
>>>>>
>>>>> color = np.array([(1, 2, 3), (4, 5, 6)],
>>
>> ... dtype=[('r', '<f4'), ('g', '<f4'), ('b',
>> '<f4')])
>> # get the average (grayscale) of the first row
>>
>>>>> color[0].mean()
>
> What about
> color.view((float,3))[0].mean() ?
Yeah, that works perfectly; by specifying the axis and dropping the
index (`color.view(('<f4',3)).mean(axis=1)) gives the mean of all the
records.
BTW, is the tuple argument you use with `view` documented anywhere; I
haven't seen it before and a quick search doesn't give any results.
Thanks!
-Tony
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion