[Numpy-discussion] array with named columns (or record arrays with homogenous types)
Pierre GM
pgmdevlist at gmail.com
Mon Sep 22 19:28:50 EDT 2008
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() ?
More information about the NumPy-Discussion
mailing list