Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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
Jump to file or symbol
Failed to load files and symbols.
+14 −2
Split
View
@@ -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`).
View
@@ -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
@@ -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