Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Series.argmax() fails with np.inf #16449

Merged
merged 1 commit into from
Aug 15, 2017
Merged

Commits on Aug 14, 2017

  1. BUG: Fix behavior of argmax and argmin with inf (pandas-dev#16449)

    Closes pandas-dev#13595
    
    The implementations of `nanargmin` and `nanargmax` in `nanops` were
    forcing the `_get_values` utility function to always mask out infinite
    values. For example, in `nanargmax`,
    
        >>> nanops._get_values(np.array([1, np.nan, np.inf]), True,
        isfinite=True, fill_value_typ='-inf')
    
        (array([  1., -inf, -inf]),
         array([False,  True,  True], dtype=bool),
         dtype('float64'),
         numpy.float64)
    
    The first element of the result tuple (the masked version of the
    values array) is used for actually finding the max or min argument. As
    a result, infinite values could never be correctly recognized as the
    maximum or minimum values in an array.
    
    This also affects the behavior of `Series.idxmax` with string data (or
    the `object` dtype generally). Previously, `nanargmax` would always
    attempt to coerce its input to float, even when there were no missing
    values. Now, it will not, and so will work correctly in the particular
    case of a `Series` of strings with no missing values. However, because
    it's difficult to ensure that `nanargmin` and `nanargmax` will behave
    consistently for arbitrary `Series` of `object` with and without
    missing values, these functions are now explicitly disallowed for
    `object`.
    DGrady authored and Daniel Grady committed Aug 14, 2017
    Configuration menu
    Copy the full SHA
    9a3d62d View commit details
    Browse the repository at this point in the history