diff --git a/doc/source/v0.15.0.txt b/doc/source/v0.15.0.txt index f73c080b6e71d..aaf9830b22f56 100644 --- a/doc/source/v0.15.0.txt +++ b/doc/source/v0.15.0.txt @@ -480,7 +480,6 @@ Enhancements -- Bug in ``DataFrame.groupby`` where ``Grouper`` does not recognize level when frequency is specified (:issue:`7885`) @@ -538,7 +537,9 @@ There are no experimental changes in 0.15.0 Bug Fixes ~~~~~~~~~ +- Bug in ``read_csv`` where ``squeeze=True`` would return a view (:issue:`8217`) - Bug in checking of table name in ``read_sql`` in certain cases (:issue:`7826`). +- Bug in ``DataFrame.groupby`` where ``Grouper`` does not recognize level when frequency is specified (:issue:`7885`) - Bug in multiindexes dtypes getting mixed up when DataFrame is saved to SQL table (:issue:`8021`) - Bug in Series 0-division with a float and integer operand dtypes (:issue:`7785`) - Bug in ``Series.astype("unicode")`` not calling ``unicode`` on the values correctly (:issue:`7758`) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 6d2afbad36e35..3a5b3af7b4c74 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -703,7 +703,7 @@ def read(self, nrows=None): df = DataFrame(col_dict, columns=columns, index=index) if self.squeeze and len(df.columns) == 1: - return df[df.columns[0]] + return df[df.columns[0]].copy() return df def _create_index(self, ret): diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py index 14e69179f9ff4..f2b9a9447e8fb 100644 --- a/pandas/io/tests/test_parsers.py +++ b/pandas/io/tests/test_parsers.py @@ -263,6 +263,15 @@ def test_squeeze(self): tm.assert_isinstance(result, Series) tm.assert_series_equal(result, expected) + def test_squeeze_no_view(self): + + # GH 8217 + # series should not be a view + + data = """time,data\n0,10\n1,11\n2,12\n4,14\n5,15\n3,13""" + result = self.read_csv(StringIO(data), index_col='time', squeeze=True) + self.assertFalse(result._is_view) + def test_inf_parsing(self): data = """\ ,A