Skip to content

BUG: min on non-numeric data with nans #4147

Open
@hayd

Description

@hayd

related #4279
related #5967

Min doesn't seem to work as expected with NaNs and non-numeric data:

In [1]: s = pd.Series(['alpha', np.nan, 'charlie', 'delta'])

In [2]: s
Out[2]:
0      alpha
1        NaN
2    charlie
3      delta
dtype: object

In [3]: s.min()  # by default docstring suggests this should skipnan
Out[3]: inf

The hack/workaround is to exclude them, perhaps we should special case this in the code:

In [4]: s[s.notnull()].min()
Out[4]: 'alpha'

From discussion on this pandas SO question. and I also posted a corresponding numpy issue:
numpy/numpy#3508
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions