diff --git a/RELEASE.rst b/RELEASE.rst index eab72dd47d720..8f46a92285bcd 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -126,6 +126,8 @@ pandas 0.9.0 - Prevent segfault due to MultiIndex not being supported in HDFStore table format (#1848) - Fix UnboundLocalError in Panel.__setitem__ and add better error (#1826) + - Fix to_csv issues with list of string entries. Isnull works on list of + strings now too (#1791) pandas 0.8.1 ============ diff --git a/pandas/core/common.py b/pandas/core/common.py index b398d51bdf4d4..47e8a46f5b796 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -73,9 +73,13 @@ def _isnull_ndarraylike(obj): if values.dtype.kind in ('O', 'S'): # Working around NumPy ticket 1542 shape = values.shape - result = np.empty(shape, dtype=bool) - vec = lib.isnullobj(values.ravel()) - result[:] = vec.reshape(shape) + + if values.dtype.kind == 'S': + result = np.zeros(values.shape, dtype=bool) + else: + result = np.empty(shape, dtype=bool) + vec = lib.isnullobj(values.ravel()) + result[:] = vec.reshape(shape) if isinstance(obj, Series): result = Series(result, index=obj.index, copy=False) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3b816e860763a..275b9505c29cb 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1088,7 +1088,7 @@ def _helper_csvexcel(self, writer, na_rep=None, cols=None, row_fields = list(idx) for i, col in enumerate(cols): val = series[col][j] - if isnull(val): + if lib.checknull(val): val = na_rep if float_format is not None and com.is_float(val): val = float_format % val diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index c00f14d1c3463..f7c6420f69577 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -50,6 +50,10 @@ def test_isnull_lists(): exp = np.array([[False], [False]]) assert(np.array_equal(result, exp)) + # list of strings + result = isnull(['foo', 'bar']) + assert(not result.any()) + def test_isnull_datetime(): assert (not isnull(datetime.now())) assert notnull(datetime.now()) diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 9f44e455ba2ed..e45cdb7646487 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -2028,6 +2028,14 @@ def test_to_csv_float_format(self): assert_series_equal(rs, xp) os.remove(filename) + def test_to_csv_list_entries(self): + s = Series(['jack and jill','jesse and frank']) + + split = s.str.split(r'\s+and\s+') + + buf = StringIO() + split.to_csv(buf) + def test_clip(self): val = self.ts.median()