Skip to content

Series methods isnull and notnull #209

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

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 4 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ def to_csv(self, path):
path : string or None
Output filepath. If None, write to stdout
"""
f = open(path, 'wb')
f = open(path, 'w')
csvout = csv.writer(f)
csvout.writerows(self.iteritems())
f.close()
Expand All @@ -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
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering',
]
Expand Down