[SciPy-User] Extracting float vector from tuple vector
Robert Kern
robert.kern@gmail....
Mon Oct 26 17:14:29 CDT 2009
On Mon, Oct 26, 2009 at 17:08, Ian Stokes-Rees
<ijstokes@crystal.harvard.edu> wrote:
> Take 3 at sending this:
>
>> I have a vector that is defined as follows:
>>
>> dtype = [("score", "f4"), ("rfac", "f4"), ("codefull", "a10"),
>> ("code2", "a2"), ("subset","a4"), ("source","a10")]
>> results = np.zeros((entry_count,), dtype=dtype)
>>
>> What I'd love to be able to do is to refer to a "slice" taken from a
>> selection of rows, and only one tuple entry, e.g.:
>>
>> results[:]["score"]
>>
>> would return a vector of "f4" floats only, from the first entry of
>> every tuple in results.
>>
>> I can't figure out how to do this!
You just did it. Although "results['score']" amounts to basically the
same thing with less fuss.
--
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
More information about the SciPy-User
mailing list