The signature could be: def median(it, exclude=None):
With *exclude* being a value, or collection supporting the *in* operator On Thu, Dec 26, 2019 at 4:14 PM David Mertz <[email protected]> wrote: > Maybe we can just change the function signature: > > statistics.median(it, do_wrong_ass_thing_with_nans=False) > > :-) > > But yes, the problem is really with sorted(). However, the implementation > of statistics.median() doesn't HAVE TO use sorted(), that's just one > convenient way to do it. > > There IS NO right answer for `sorted([nan, 1, 2, 3])`. However, there is > a very plausibly right answer for `statistics.median([nan, 1, 2, 3])` ... > or rather, both 'nan' and '2' are plausible (one approach is what Numpy > does, the other is what Pandas does). > > -- > Keeping medicines from the bloodstreams of the sick; food > from the bellies of the hungry; books from the hands of the > uneducated; technology from the underdeveloped; and putting > advocates of freedom in prisons. Intellectual property is > to the 21st century what the slave trade was to the 16th. > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/524SWHDA3HVPDIQ6F6S3OMFGFXPCVGLO/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Juancarlo *Añez*
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/TRN2MKZQ5RUHVWBVWG3VG5FBPNPPOCVF/ Code of Conduct: http://python.org/psf/codeofconduct/
