Skip to content

Commit 252aa6c

Browse files
committed
Merge pull request #5918 from jreback/index_float
BUG: Bug in idxmin/max with object dtypes (GH5914)
2 parents 1e5f94a + 30a007d commit 252aa6c

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Bug Fixes
8686
- Testing bug in reading json/msgpack from a non-filepath on windows under py3 (:issue:`5874`)
8787
- Bug when assigning to .ix[tuple(...)] (:issue:`5896`)
8888
- Bug in fully reindexing a Panel (:issue:`5905`)
89+
- Bug in idxmin/max with object dtypes (:issue:`5914`)
8990

9091
pandas 0.13.0
9192
-------------

pandas/core/nanops.py

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ def _get_values(values, skipna, fill_value=None, fill_value_typ=None,
171171
def _isfinite(values):
172172
if issubclass(values.dtype.type, (np.timedelta64, np.datetime64)):
173173
return isnull(values)
174+
elif isinstance(values.dtype, object):
175+
return -np.isfinite(values.astype('float64'))
176+
174177
return -np.isfinite(values)
175178

176179

pandas/tests/test_series.py

+14
Original file line numberDiff line numberDiff line change
@@ -3258,6 +3258,20 @@ def test_idxmax(self):
32583258
result = s.idxmax()
32593259
self.assert_(result == 4)
32603260

3261+
# Float64Index
3262+
# GH 5914
3263+
s = pd.Series([1,2,3],[1.1,2.1,3.1])
3264+
result = s.idxmax()
3265+
self.assert_(result == 3.1)
3266+
result = s.idxmin()
3267+
self.assert_(result == 1.1)
3268+
3269+
s = pd.Series(s.index, s.index)
3270+
result = s.idxmax()
3271+
self.assert_(result == 3.1)
3272+
result = s.idxmin()
3273+
self.assert_(result == 1.1)
3274+
32613275
def test_ndarray_compat(self):
32623276

32633277
# test numpy compat with Series as sub-class of NDFrame

0 commit comments

Comments
 (0)