[Numpy-discussion] Count the occurrence of a certain integer in a list of integers
Nils Wagner
nwagner at iam.uni-stuttgart.de
Tue Aug 7 09:22:37 EDT 2007
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, 7, 9, 7, 8, 9, 8, 7, 9]
>> Is there a better way than using, e.g.
>>
>>>>> shape(where(array(data)==10))[1]
>>>>>
>> 2
>>
>
>
> You did not say why data.count(10) is unsatisfactory ...
>
> Cheers,
> Alan Isaac
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
Thank you for all your input. To be honest I was not aware of all these
possibilities to solve my problem.
If you distribute a task among different people you will obtain
different methods of resolution.
Nils
More information about the NumPy-Discussion
mailing list