Skip to content

BUG: PEBKAC bug in Float64Index #7068

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

Merged
merged 2 commits into from
May 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ Bug Fixes
caused possible color/class mismatch (:issue:`6956`)
- Bug in ``radviz`` and ``andrews_curves`` where multiple values of 'color'
were being passed to plotting method (:issue:`6956`)
- Bug in ``Float64Index.isin()`` where containing ``nan`` s would make indices
claim that they contained all the things (:issue:`7066`).

pandas 0.13.1
-------------
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,8 @@ def isin(self, values):
"""
value_set = set(values)
return lib.ismember_nans(self._array_values(), value_set,
self._hasnans)
isnull(list(value_set)).any())


class MultiIndex(Index):

Expand Down
19 changes: 19 additions & 0 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,25 @@ def test_contains_not_nans(self):
i = Float64Index([1.0, 2.0, np.nan])
self.assertTrue(1.0 in i)

def test_doesnt_contain_all_the_things(self):
i = Float64Index([np.nan])
self.assertFalse(i.isin([0]).item())
self.assertFalse(i.isin([1]).item())
self.assertTrue(i.isin([np.nan]).item())

def test_nan_multiple_containment(self):
i = Float64Index([1.0, np.nan])
np.testing.assert_array_equal(i.isin([1.0]), np.array([True, False]))
np.testing.assert_array_equal(i.isin([2.0, np.pi]),
np.array([False, False]))
np.testing.assert_array_equal(i.isin([np.nan]),
np.array([False, True]))
np.testing.assert_array_equal(i.isin([1.0, np.nan]),
np.array([True, True]))
i = Float64Index([1.0, 2.0])
np.testing.assert_array_equal(i.isin([np.nan]),
np.array([False, False]))


class TestInt64Index(tm.TestCase):
_multiprocess_can_split_ = True
Expand Down