David Mertz wrote: > So we could get the Pandas-style behavior simply by calling median like so: > statistics.median((x for x in it if not math.isnan(x)))
This is wrong. Or maybe potentially wrong. This way you're removing items from the iterable, so you're moving the median. If the NaNs are not really member of your population, it's ok. On the contrary, if you use my median function with the key function I posted before, you have not this problem. The iterable is sorted well and you get the real median. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7WU5GQ7IIXAHT42KYKGRVC5X24QTM5QY/ Code of Conduct: http://python.org/psf/codeofconduct/