unzip array of arrays?
Robert Kern
robert.kern at gmail.com
Thu Jan 22 17:57:02 EST 2009
Unknown wrote:
> On 2009-01-22, Tobiah <toby at tobiah.org> wrote:
>> Although it's trivial to program, I wondered whether
>> there was a builtin or particularly concise way to
>> express this idea:
>>
>>> a = [(1, 2), (3, 4), (5, 6)]
>>> field[a, 2]
>> [2, 4, 6]
>>
>> where field() is some made up function.
>
> The above example is a great application for numpy's array
> type:
>
> http://numpy.scipy.org/
>
> Here's an example showing how you extract a column using
> indexing operations:
>
> http://www.scipy.org/Tentative_NumPy_Tutorial#head-864862d3f2bb4c32f04260fac61eb4ef34788c4c
>
> [I assume numpy is still the numerical/array package du jour?]
Yes.
--
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 Python-list
mailing list