From 3406547d10981a28bb2fe0985d2fc5a8b4ea4d5d Mon Sep 17 00:00:00 2001 From: Pradyumna Reddy Date: Sun, 4 Jun 2017 16:24:51 +0530 Subject: [PATCH 1/3] bug fix #16524 --- doc/source/whatsnew/v0.20.2.txt | 1 + pandas/core/internals.py | 2 +- pandas/tests/series/test_dtypes.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.2.txt b/doc/source/whatsnew/v0.20.2.txt index 31125db0f34d4..57902ec1e49f0 100644 --- a/doc/source/whatsnew/v0.20.2.txt +++ b/doc/source/whatsnew/v0.20.2.txt @@ -57,6 +57,7 @@ Conversion - Bug in :func:`to_numeric` in which empty data inputs were causing a segfault of the interpreter (:issue:`16302`) - Silence numpy warnings when broadcasting ``DataFrame`` to ``Series`` with comparison ops (:issue:`16378`, :issue:`16306`) +- Bug in ``Series`` with ``dtype='category'`` (:issue:`16524`) Indexing diff --git a/pandas/core/internals.py b/pandas/core/internals.py index 58690ad632152..f2a7ac76481d4 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -471,7 +471,7 @@ def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs): **kwargs) def _astype(self, dtype, copy=False, errors='raise', values=None, - klass=None, mgr=None, **kwargs): + klass=None, mgr=None, raise_on_error=False, **kwargs): """ Coerce to the new type (if copy=True, return a new copy) raise on an except if raise == True diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index e084fa58d6c51..9ab02a8c2aad7 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -248,3 +248,12 @@ def test_intercept_astype_object(self): result = df.values.squeeze() assert (result[:, 0] == expected.values).all() + + def test_series_to_categorical(self): + # see gh-16524: test conversion of Series to Categorical + series = Series(['a', 'b', 'c']) + + result = Series(series, dtype='category') + expected = Series(['a', 'b', 'c'], dtype='category') + + tm.assert_series_equal(result, expected) From a298430f5877b0017ef78707f693955dbdfeaac6 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 7 Jun 2017 16:27:16 -0500 Subject: [PATCH 2/3] DOC: move release note --- doc/source/whatsnew/v0.20.2.txt | 1 - doc/source/whatsnew/v0.20.3.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.2.txt b/doc/source/whatsnew/v0.20.2.txt index 57902ec1e49f0..31125db0f34d4 100644 --- a/doc/source/whatsnew/v0.20.2.txt +++ b/doc/source/whatsnew/v0.20.2.txt @@ -57,7 +57,6 @@ Conversion - Bug in :func:`to_numeric` in which empty data inputs were causing a segfault of the interpreter (:issue:`16302`) - Silence numpy warnings when broadcasting ``DataFrame`` to ``Series`` with comparison ops (:issue:`16378`, :issue:`16306`) -- Bug in ``Series`` with ``dtype='category'`` (:issue:`16524`) Indexing diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index 2032209c4aa23..64dfe02673e77 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -44,6 +44,7 @@ Conversion ^^^^^^^^^^ - Bug in pickle compat prior to the v0.20.x series, when ``UTC`` is a timezone in a Series/DataFrame/Index (:issue:`16608`) +- Bug in ``Series`` with ``dtype='category'`` (:issue:`16524`) Indexing ^^^^^^^^ From 795575a07e36cdfeae2d3c8b41cbcdce3506365c Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 9 Jun 2017 17:49:53 +0200 Subject: [PATCH 3/3] edit whatsnew message --- doc/source/whatsnew/v0.20.3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index 64dfe02673e77..83cd5cc4b470c 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -44,7 +44,7 @@ Conversion ^^^^^^^^^^ - Bug in pickle compat prior to the v0.20.x series, when ``UTC`` is a timezone in a Series/DataFrame/Index (:issue:`16608`) -- Bug in ``Series`` with ``dtype='category'`` (:issue:`16524`) +- Bug in Series construction when passing a Series with ``dtype='category'`` (:issue:`16524`). Indexing ^^^^^^^^