BUG: min on non-numeric data with nans · Issue #4147 · pandas-dev/pandas (original) (raw)

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.