[Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-08 Thread Mark.Miller
A late entry, but here's something that gets you an array of counts for each unique integer: >>> data = numpy.array([9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 7, 8, 9, 8, 7, 9]) >>> unique=numpy.unique(data) >>> unique array([ 6, 7, 8, 9, 10, 11]) >>> hist

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Nils Wagner
Alan G Isaac wrote: > On Tue, 07 Aug 2007, Nils Wagner apparently wrote: > >> I have a list of integer numbers. The entries can vary between 0 and 19. >> How can I count the occurrence of any number. Consider >> >>> data >> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9,

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Alan G Isaac
By the way, you can get all the frequencies pretty fast using a defaultdict: http://docs.python.org/lib/defaultdict-examples.html Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listi

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Alan G Isaac
On Tue, 07 Aug 2007, Nils Wagner apparently wrote: > I have a list of integer numbers. The entries can vary between 0 and 19. > How can I count the occurrence of any number. Consider > >>> data > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, > 7, 8, 9, 8, 7, 9] >

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Robert Cimrman
Nils Wagner wrote: > Hi all, > > I have a list of integer numbers. The entries can vary between 0 and 19. > How can I count the occurrence of any number. Consider > > >>> data > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, > 7, 8, 9, 8, 7, 9] > > > Is there a be

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Keith Goodman
On 8/7/07, Keith Goodman <[EMAIL PROTECTED]> wrote: > On 8/7/07, Nils Wagner <[EMAIL PROTECTED]> wrote: > > I have a list of integer numbers. The entries can vary between 0 and 19. > > How can I count the occurrence of any number. Consider > > > > >>> data > > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6,

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Keith Goodman
On 8/7/07, Nils Wagner <[EMAIL PROTECTED]> wrote: > I have a list of integer numbers. The entries can vary between 0 and 19. > How can I count the occurrence of any number. Consider > > >>> data > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, > 7, 8, 9, 8, 7, 9] > >

Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Matthieu Brucher
You can try using hist() with the correct range and number of bins. Matthieu 2007/8/7, Nils Wagner <[EMAIL PROTECTED]>: > > Hi all, > > I have a list of integer numbers. The entries can vary between 0 and 19. > How can I count the occurrence of any number. Consider > > >>> data > [9, 6, 9, 6, 7,

[Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Nils Wagner
Hi all, I have a list of integer numbers. The entries can vary between 0 and 19. How can I count the occurrence of any number. Consider >>> data [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 7, 8, 9, 8, 7, 9] Is there a better way than using, e.g. >>> shape(wher