Skip to content

Commit 59110fd

Browse files
committed
BUG: PEBKAC bug in Float64Index
1 parent 3d2c80f commit 59110fd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ Bug Fixes
475475
caused possible color/class mismatch (:issue:`6956`)
476476
- Bug in ``radviz`` and ``andrews_curves`` where multiple values of 'color'
477477
were being passed to plotting method (:issue:`6956`)
478+
- Bug in ``Float64Index.isin()`` where containing ``nan`` s would make indices
479+
claim that they contained all the things (:issue:`7066`).
478480

479481
pandas 0.13.1
480482
-------------

pandas/core/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,8 @@ def isin(self, values):
20962096
"""
20972097
value_set = set(values)
20982098
return lib.ismember_nans(self._array_values(), value_set,
2099-
self._hasnans)
2099+
isnull(list(value_set)).any())
2100+
21002101

21012102
class MultiIndex(Index):
21022103

pandas/tests/test_index.py

+6
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,12 @@ def test_contains_not_nans(self):
913913
i = Float64Index([1.0, 2.0, np.nan])
914914
self.assertTrue(1.0 in i)
915915

916+
def test_doesnt_contain_all_the_things(self):
917+
i = Float64Index([np.nan])
918+
self.assertFalse(i.isin([0]).item())
919+
self.assertFalse(i.isin([1]).item())
920+
self.assertTrue(i.isin([np.nan]).item())
921+
916922

917923
class TestInt64Index(tm.TestCase):
918924
_multiprocess_can_split_ = True

0 commit comments

Comments
 (0)