Any users of statistics.mode() here?

MRAB python at mrabarnett.plus.com
Tue Feb 20 15:51:58 EST 2018


On 2018-02-20 20:20, Jason Friedman wrote:
>> statistics.mode() currently raises an exception if there is more than one
>> mode.
>>
> 
> I am an infrequent user of this package and this function.  My two cents:
> * Leave the current behavior as-is.
> * Continue to throw an exception for no data.
> * Add an argument, named perhaps mutli=False, that if set to True causes
> the function to a return a list of modes, including if there is only a
> single mode.  statistics.mode((1, 2, 2, 3, 3, 4, 4, 5), multi=True) would
> return [2, 3, 4].
> * Would still throw StatisticsError if no data or if every element occurs
> exactly the same number of times (for example,
> statistics.mode(range(1000000000), multi=True))
> 
I think that it would be better to have a separate function instead of 
having the function sometimes return a single value and sometimes a list 
of values.

There's an interesting answer here:

http://mathforum.org/library/drmath/view/61375.html



More information about the Python-list mailing list