[Numpy-discussion] field names on numpy arrays
Wed Jun 3 18:20:43 CDT 2009
On Jun 3, 2009, at 5:03 PM, Robert Kern wrote:
> On Wed, Jun 3, 2009 at 15:26, <firstname.lastname@example.org> wrote:
>> 2009/6/3 Stéfan van der Walt <email@example.com>:
>>> Hi Jon
>>> 2009/6/3 D2Hitman <firstname.lastname@example.org>:
>>>> I understand record arrays such as:
>>>> a_array =
>>>> do this with field names.
>>>> a_array['a'] = array([ 0., 1.], dtype=float32)
>>>> however i seem to lose simple operations such as multiplication
>>>> or powers (a_array**2).
>> Why does it not preserve "shape", to do e.g. np.mean by axis?
> It does preserve the shape. The input and output are both 1D. If you
> need a different shape (e.g. re-interpreting the record as another
> axis), you need to reshape it yourself. numpy can't guess what you
Or, as all fields have the same dtype:
array([[ 0., 1., 2., 3., 4.],
[ 1., 2., 3., 4., 5.]], dtype=float32)
Ain't it fun ?
More information about the Numpy-discussion