[New-bugs-announce] [issue30999] statistics module: add "key" keyword argument to median, mode, ...

gerion report at bugs.python.org
Sun Jul 23 18:10:22 EDT 2017


New submission from gerion:

With Python 3.4 the statistics module was added. It would be cool, if the functions:
median_low()
median_high()
mode()
would have a "key" keyword argument, just like in max() and min():
```
>>> median_low([(1, 2), (3, 3), (4, 1)], key=lambda elem: elem[0])
(3, 3)
```
This functions always choose a specific element of the list, so a "key" argument is meaningful.


Maybe such a parameter makes sense for mean() as well, if the return value always is the result itself, but this is another point:
```
>>> mean([(1, 2), (3, 3), (4, 1)], key=lambda elem: elem[0])
2.6666666666666665
```

----------
components: Library (Lib)
messages: 298918
nosy: gerion
priority: normal
severity: normal
status: open
title: statistics module: add "key" keyword argument to median, mode, ...
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30999>
_______________________________________


More information about the New-bugs-announce mailing list