Skip to content
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

BUG: isnull doesn't properly check for inf when requested #7315

Merged
merged 1 commit into from
Jun 3, 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
3 changes: 3 additions & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ Bug Fixes
(:issue:`7140`).
- Bug in ``StringMethods.extract()`` where a single match group Series
would use the matcher's name instead of the group name (:issue:`7313`).
- Bug in ``isnull()`` when ``mode.use_inf_as_null == True`` where isnull
wouldn't test ``True`` when it encountered an ``inf``/``-inf``
(:issue:`7315`).
3 changes: 1 addition & 2 deletions pandas/src/util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ cdef inline bint _checknull_old(object val):
cdef double INF = <double> np.inf
cdef double NEGINF = -INF
try:
return bool(val is None or val != val and val != INF
and val != NEGINF)
return val is None or val != val or val == INF or val == NEGINF
except ValueError:
return False

Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2941,6 +2941,16 @@ def test_raise_on_info(self):
with tm.assertRaises(AttributeError):
s.info()

def test_isnull_for_inf(self):
s = Series(['a', np.inf, np.nan, 1.0])
with pd.option_context('mode.use_inf_as_null', True):
r = s.isnull()
dr = s.dropna()
e = Series([False, True, True, False])
de = Series(['a', 1.0], index=[0, 3])
tm.assert_series_equal(r, e)
tm.assert_series_equal(dr, de)


# TimeSeries-specific

Expand Down