Message 336432 - Python tracker

Message336432

Author tim.peters
Recipients brandtbucher, cheryl.sabella, mark.dickinson, rhettinger, serhiy.storchaka, tim.peters
Date 2019-02-24.04:36:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550982961.8.0.68587912094.issue36095@roundup.psfhosted.org>
In-reply-to
Content
If we could roll back the clock, I'd impose a total ordering on floats in Python and supply some other way to spell 754's comparison operators (which users would have to ask for explicitly if they wanted to hassle with the near-useless and too-often-surprising "unordered" outcome).

But, too late.  As is, I don't want to mess up every context that _uses_ comparisons under the covers to make a special case out of NaNs.  Floats are a partially ordered type, and live with the consequences.

Which are approximately none for me ;-)  I rarely have a use for a NaN to begin with, and never in a list I intend to sort.

That said, the one thing that gives me pause is this line from numpy's docs:

   https://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html
    "In numpy versions >= 1.4.0 nan values are sorted to the end."

But that's not the end of it:

    https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html
    ...
    na_position : {‘first’, ‘last’}, default ‘last’
    first puts NaNs at the beginning, last puts NaNs at the end

So people who go down this path can't get two steps before making a fork in the road ;-)
History
Date User Action Args
2019-02-24 04:36:01tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, serhiy.storchaka, cheryl.sabella, brandtbucher
2019-02-24 04:36:01tim.peterssetmessageid: <1550982961.8.0.68587912094.issue36095@roundup.psfhosted.org>
2019-02-24 04:36:01tim.peterslinkissue36095 messages
2019-02-24 04:36:01tim.peterscreate