Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

My recommendation is to have *weights* as an optional argument:

    statistics.mean(values, weights=None)

While it is tempting to special case dicts and counters, I got feedback from 
Jake Vanderplas and Wes McKinney that in practice it is more common to have the 
weights as a separate list/array/vector.

That API has other advantages as well.  For starters, it is a simple extension 
of the existing API, so it isn't a disruptive change.  Also, it works well with 
mapping views: 
   
   statistics.mean(vehicle_sales.keys(), vehicle_sales.values())

And the API also helps support use cases where different weightings are being 
explored for the same population:

   statistics.mean(salary, years_of_service)
   statistics.mean(salary, education)
   statistics.mean(salary, age)

----------
nosy: +rhettinger
versions: +Python 3.7 -Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue20479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to