[Numpy-discussion] Dealing with arrays

Olivier Delalleau shish at keba.be
Tue Sep 20 12:32:57 EDT 2011


I'm trying to understand what you want to do, but I'm afraid it's still not
clear, so I'm sorry if that reply doesn't help either.

It looks to me as if you first want to convert your list of lists into a
list of arrays, then iterate through this list of arrays.
If that's it, then you can just do:

def p(option_lists):
    list_of_arrays = map(numpy.array, option_lists)
    for my_array in list_of_arrays:
        ... # Do some operation on array 'my_array'

-=- Olivier

2011/9/20 DIPO ELEGBEDE <dipo.elegbede at gmail.com>

> I think that should sort it.
>
> def p(option_lists):
>     for option_list in option_lists:
>         array = numpy.array(option_list)
>         for i in array: print i
>
> the option_lists here is the list of lists
> looping through it and then converting it into a numpy array is quiet easy.
>
> If I try to loop through the array as you adviced, it prints out the whole
> items in the array.
>
> You could also try that out.
>
> What I am trying to achieve however is to loop through the 12 arrays and
> get them one after the other, doing something like:
>
> for my_array in list_of_arrays:
>   print my_array[0]
>
>
> Hope this is clear enough.
> Thanks for your patience.
>
>
> On 20 September 2011 17:11, Olivier Delalleau <shish at keba.be> wrote:
>
>> Can you please provide your current code, even if incomplete / not
>> working? It's hard to tell what's wrong without looking at the code.
>>
>> -=- Olivier
>>
>> 2011/9/20 <dipo.elegbede at gmail.com>
>>
>>> Olivier, the code you sent did so much magic and I'm definitely using
>>> that.
>>>
>>> What baffles me is that looping through the 12 arrays seem impossible.
>>> I have tried what you just sent but it won't just work.
>>> You could confirm this.
>>> Sent from my BlackBerry wireless device from MTN
>>>
>>> -----Original Message-----
>>> From: Olivier Delalleau <shish at keba.be>
>>> Sender: numpy-discussion-bounces at scipy.org
>>> Date: Tue, 20 Sep 2011 12:00:51
>>> To: Discussion of Numerical Python<numpy-discussion at scipy.org>
>>> Reply-To: Discussion of Numerical Python <numpy-discussion at scipy.org>
>>> Subject: Re: [Numpy-discussion] Dealing with arrays
>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
>
> --
> Dipo Elegbede,OCA
> 08033299270,08077682428
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110920/17bae767/attachment.html>


More information about the NumPy-Discussion mailing list