[Numpy-discussion] view of a structured array?
Chris Barker
chris.barker@noaa....
Wed Jan 25 17:19:33 CST 2012
On Wed, Jan 25, 2012 at 11:33 AM, <josef.pktd@gmail.com> wrote:
> that's what I would try:
>
>>>> b = a.view(dtype=[('i', '<i4'), ('fl',[('f1', '<f8'), ('f2', '<f8')]), ('i2', '<i4')])
ah yes, I forgot about nesting dtypes -- very nice, thanks!
-Chris
>>>> b['fl']
> array([(2.0, 3.0), (8.0, 9.0), (123.40000000000001, 7.0), (10.0, 11.0),
> (14.0, 15.0)],
> dtype=[('f1', '<f8'), ('f2', '<f8')])
>>>> b['fl'][2]= (200, 500)
>>>> a
> array([(1, 2.0, 3.0, 4), (7, 8.0, 9.0, 10), (5, 200.0, 500.0, 8),
> (9, 10.0, 11.0, 12), (13, 14.0, 15.0, 16)],
> dtype=[('i', '<i4'), ('f1', '<f8'), ('f2', '<f8'), ('i2', '<i4')])
>
> Josef
>>
>>
>>
>> --
>> --
>>
>> Christopher Barker, Ph.D.
>> Oceanographer
>>
>> Emergency Response Division
>> NOAA/NOS/OR&R (206) 526-6959 voice
>> 7600 Sand Point Way NE (206) 526-6329 fax
>> Seattle, WA 98115 (206) 526-6317 main reception
>>
>> Chris.Barker@noaa.gov
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the NumPy-Discussion
mailing list