Yes. Like Pandas does! Like I wrote!

And yes, it is one of three plausible good behaviors that Steven described
well. Which is kinda why is still like a named parameter like 'on_nan' to
choose which behavior you want inside the function.

Unfortunately, propogating/poisoning NaN like NumPy does cannot really be
done with a comprehension, so doing it in the function makes sense. Similar
with raising an exception.

On Thu, Dec 26, 2019, 9:35 PM Marco Sulla via Python-ideas <
python-ideas@python.org> wrote:

> 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/
>
_______________________________________________
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/NGYQK326O4HZYFCUNFG44IQGKVCNY2ZF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to