On Mar 30, 10:17 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 29 Mar 2007 19:44:56 -0300, Paddy <[EMAIL PROTECTED]>
> escribió:
>
> > On Mar 29, 8:49 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> >> >>> foo = ["spam", "eggs", "spam", "spam", "spam", "beans", "eggs"]
> >> >>> max(fo
En Thu, 29 Mar 2007 19:44:56 -0300, Paddy <[EMAIL PROTECTED]>
escribió:
> On Mar 29, 8:49 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
>> >>> foo = ["spam", "eggs", "spam", "spam", "spam", "beans", "eggs"]
>> >>> max(foo, key=foo.count)
>>
>> 'spam'
>
> This doesn't call foo.count for duplicate
On Mar 30, 2:58 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Paddy <[EMAIL PROTECTED]> wrote:
>
>...
>
>
>
> > > A bit more directly:
>
> > > >>> foo = ["spam", "eggs", "spam", "spam", "spam", "beans", "eggs"]
> > > >>> max(foo, key=foo.count)
>
> > > 'spam'
>
> > > Alex
>
> > This doesn't ca
Paddy <[EMAIL PROTECTED]> wrote:
...
> > A bit more directly:
> >
> > >>> foo = ["spam", "eggs", "spam", "spam", "spam", "beans", "eggs"]
> > >>> max(foo, key=foo.count)
> >
> > 'spam'
> >
> > Alex
>
> This doesn't call foo.count for duplicate entries by keeping a cache
>
> >>> foo = ["spam",
On Mar 29, 8:49 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Ben Finney <[EMAIL PROTECTED]> wrote:
>
>...
>
> > That's not the only case though. What do you expect to be returned for
> > an input of ["eggs", "beans", "beans", "eggs", "spam"] ?
>
> > Assuming you want *a* mode value, and any o
Alex Martelli:
> >>> foo = ["spam", "eggs", "spam", "spam", "spam", "beans", "eggs"]
> >>> max(foo, key=foo.count)
It's a very nice solution, the shortest too. But I think it's better
to develop your own well tested and efficient stats module (and there
is one already done that can be found around
Ben Finney <[EMAIL PROTECTED]> wrote:
...
> That's not the only case though. What do you expect to be returned for
> an input of ["eggs", "beans", "beans", "eggs", "spam"] ?
>
> Assuming you want *a* mode value, and any one will do (e.g. any of
> "spam", "eggs" or "beans" is okay), I'd write it
On Mar 29, 4:40 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi
>
> How can I find out the modal value in an array. That is the value
> which occurs maximum time in the sequence ..
>
> e.g. if my array has values like [2,3,2,2,2,4,2,2] definitely the
> maximum time 2 occurs in the array.
On Wed, 28 Mar 2007 20:40:22 -0700, [EMAIL PROTECTED] wrote:
> Hi
>
> How can I find out the modal value in an array. That is the value
> which occurs maximum time in the sequence ..
>
> e.g. if my array has values like [2,3,2,2,2,4,2,2] definitely the
> maximum time 2 occurs in the array. so
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> Hi
>
> How can I find out the modal value in an array. That is the value
> which occurs maximum time in the sequence ..
>
> e.g. if my array has values like [2,3,2,2,2,4,2,2] definitely the
> maximum time 2 occurs in the array. so this function s
10 matches
Mail list logo