[issue33084] Computing median, median_high an median_low in statistics library

David Mertz report at bugs.python.org
Sun Jan 6 22:57:41 EST 2019


David Mertz <david.mertz at gmail.com> added the comment:

I believe that the current behavior of `statistics.median[|_low|_high\]` is simply broken.  It relies on the particular behavior of Python sorting, which only utilizes `.__lt__()` between objects, and hence does not require a total order.

I can think of absolutely no way to characterize these as reasonable results:

Python 3.7.1 | packaged by conda-forge | (default, Nov 13 2018, 09:50:42)
>>> statistics.median([9, 9, 9, nan, 1, 2, 3, 4, 5])
1
>>> statistics.median([9, 9, 9, nan, 1, 2, 3, 4])
nan

----------
nosy: +David Mertz

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33084>
_______________________________________


More information about the Python-bugs-list mailing list