unzip array of arrays?

Grant Edwards invalid at invalid
Thu Jan 22 17:12:38 EST 2009


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?]
  
-- 
Grant Edwards                   grante             Yow! WHO sees a BEACH BUNNY
                                  at               sobbing on a SHAG RUG?!
                               visi.com            



More information about the Python-list mailing list