[Numpy-discussion] Dealing with arrays

Olivier Delalleau shish@keba...
Tue Sep 20 10:30:59 CDT 2011


Here's another python 2.6 version:

import itertools
import numpy
for tmp_list in my_list:
    array = numpy.array(tmp_list)
    counts = dict((x, len(list(c))) for x, c in
itertools.groupby(sorted(array)))
    print counts


2011/9/20 <dipo.elegbede@gmail.com>

> Thanks.
> There are other computations I have to do with numpy, hence the use.
> Second, I am on python 2.6.
> Any help?
>
> Sent from my BlackBerry wireless device from MTN
>
> -----Original Message-----
> From: Olivier Delalleau <shish@keba.be>
> Sender: numpy-discussion-bounces@scipy.org
> Date: Tue, 20 Sep 2011 09:56:45
> To: Discussion of Numerical Python<numpy-discussion@scipy.org>
> Reply-To: Discussion of Numerical Python <numpy-discussion@scipy.org>
> Subject: Re: [Numpy-discussion] Dealing with arrays
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110920/eb93b1c4/attachment.html 


More information about the NumPy-Discussion mailing list