From fcbe9275c4398f71fcdaea5fff7e78b005a9513c Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 9 Oct 2011 16:54:13 +0100 Subject: [PATCH 1/3] Add isnull and notnull methods to Series. Closes gh-203 --- pandas/core/series.py | 3 +++ pandas/tests/test_series.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 7d7153668b3d4..a6bcf53eaca4a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1619,6 +1619,9 @@ def dropna(self): return remove_na(self) valid = dropna + + isnull = isnull + notnull = notnull def first_valid_index(self): """ diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index c1c38cb392e46..de4a98656546f 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -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) From 1bc9893989b351b2b6e52078bb9064e97e02ffa7 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 9 Oct 2011 16:57:50 +0100 Subject: [PATCH 2/3] Add trove classifiers for Python 3 compatibility. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index cbcf938719c00..5a8df7f28c0f3 100755 --- a/setup.py +++ b/setup.py @@ -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', ] From 0860ebee1645d65d9541b349fff63c7453820eba Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 9 Oct 2011 16:59:11 +0100 Subject: [PATCH 3/3] Fix bug writing Series to CSV in Python 3. --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index a6bcf53eaca4a..2923f4b8436fd 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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()