This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients gregory.p.smith, ncoghlan, oscarbenjamin, rhettinger, steven.daprano, wolma
Date 2017-10-28.20:01:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)
Date User Action Args
2017-10-28 20:01:32rhettingersetrecipients: + rhettinger, gregory.p.smith, ncoghlan, steven.daprano, oscarbenjamin, wolma
2017-10-28 20:01:32rhettingersetmessageid: <>
2017-10-28 20:01:32rhettingerlinkissue20479 messages
2017-10-28 20:01:31rhettingercreate