Skip to content

Commit

Permalink
Add isnull and notnull methods to Series.
Browse files Browse the repository at this point in the history
Closes gh-203
  • Loading branch information
takluyver authored and wesm committed Oct 9, 2011
1 parent 47ddcfc commit 32017fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pandas/core/series.py
Expand Up @@ -1619,6 +1619,9 @@ def dropna(self):
return remove_na(self)

valid = dropna

isnull = isnull
notnull = notnull

def first_valid_index(self):
"""
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/test_series.py
Expand Up @@ -824,6 +824,18 @@ def test_valid(self):
self.assertEqual(len(result), ts.count())

common.assert_dict_equal(result, ts, compare_keys=False)

def test_isnull(self):
ser = Series([0,5.4,3,nan,-0.001])
assert_series_equal(ser.isnull(), Series([False,False,False,True,False]))
ser = Series(["hi","",nan])
assert_series_equal(ser.isnull(), Series([False,False,True]))

def test_notnull(self):
ser = Series([0,5.4,3,nan,-0.001])
assert_series_equal(ser.notnull(), Series([True,True,True,False,True]))
ser = Series(["hi","",nan])
assert_series_equal(ser.notnull(), Series([True,True,False]))

def test_shift(self):
shifted = self.ts.shift(1)
Expand Down

0 comments on commit 32017fa

Please sign in to comment.