From 2351a2e2830dcfee722c4ef40c0830c1410bdb5f Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Mon, 19 Jun 2017 16:40:28 +0800 Subject: [PATCH 1/9] Make Series works the same as dict in pd.astype() --- doc/source/whatsnew/v0.21.0.txt | 2 ++ pandas/core/generic.py | 2 +- pandas/tests/frame/test_dtypes.py | 48 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.21.0.txt b/doc/source/whatsnew/v0.21.0.txt index de2516d75040b..d48cd3668d627 100644 --- a/doc/source/whatsnew/v0.21.0.txt +++ b/doc/source/whatsnew/v0.21.0.txt @@ -94,6 +94,8 @@ Bug Fixes Conversion ^^^^^^^^^^ +- Fix a bug when pd.astype() receive Series as `dtype` paramter, no action is taken. Now Series +`dtype` work the same as a `dict`. diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 6069757efc429..52ad0b2063ce7 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3507,7 +3507,7 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): ------- casted : type of caller """ - if isinstance(dtype, collections.Mapping): + if is_dict_like(dtype): if self.ndim == 1: # i.e. Series if len(dtype) > 1 or list(dtype.keys())[0] != self.name: raise KeyError('Only the Series name can be used for ' diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index b99a6fabfa42b..f1cc969c5824a 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -487,6 +487,54 @@ def test_astype_dict(self): assert_frame_equal(df, equiv) assert_frame_equal(df, original) + def test_astype_Series(self): + # GH16717 + a = Series(date_range('2010-01-04', periods=5)) + b = Series(range(5)) + c = Series([0.0, 0.2, 0.4, 0.6, 0.8]) + d = Series(['1.0', '2', '3.14', '4', '5.4']) + df = DataFrame({'a': a, 'b': b, 'c': c, 'd': d}) + original = df.copy(deep=True) + + # change type of a subset of columns + result = df.astype(Series({'b': 'str', 'd': 'float32'})) + expected = DataFrame({ + 'a': a, + 'b': Series(['0', '1', '2', '3', '4']), + 'c': c, + 'd': Series([1.0, 2.0, 3.14, 4.0, 5.4], dtype='float32')}) + assert_frame_equal(result, expected) + assert_frame_equal(df, original) + + result = df.astype(Series( + {'b': np.float32, + 'c': 'float32', + 'd': np.float64})) + expected = DataFrame({ + 'a': a, + 'b': Series([0.0, 1.0, 2.0, 3.0, 4.0], dtype='float32'), + 'c': Series([0.0, 0.2, 0.4, 0.6, 0.8], dtype='float32'), + 'd': Series([1.0, 2.0, 3.14, 4.0, 5.4], dtype='float64')}) + assert_frame_equal(result, expected) + assert_frame_equal(df, original) + + # change all columns + result = df.astype(Series({'a': str, 'b': str, 'c': str, 'd': str})) + assert_frame_equal(result, df.astype(str)) + assert_frame_equal(df, original) + + # error should be raised when using something other than column labels + # in the keys of the dtype dict + pytest.raises(KeyError, df.astype, Series({'b': str, 2: str})) + pytest.raises(KeyError, df.astype, Series({'e': str})) + assert_frame_equal(df, original) + + # if the dtypes provided are the same as the original dtypes, the + # resulting DataFrame should be the same as the original DataFrame + equiv = df.astype(Series({col: df[col].dtype for col in df.columns})) + assert_frame_equal(df, equiv) + assert_frame_equal(df, original) + def test_astype_duplicate_col(self): a1 = Series([1, 2, 3, 4, 5], name='a') b = Series([0.1, 0.2, 0.4, 0.6, 0.8], name='b') From 37fc5610bf12e1d4a19b3b704240a10e09c9fbb5 Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 10:02:52 +0800 Subject: [PATCH 2/9] 1. Add test to test Series.astype() as well 2. Use parametrize test instead of redundent another test 3. Add GH # in whatsnew --- doc/source/whatsnew/v0.21.0.txt | 4 +- pandas/tests/frame/test_dtypes.py | 71 +++++++----------------------- pandas/tests/series/test_dtypes.py | 15 ++++--- 3 files changed, 27 insertions(+), 63 deletions(-) diff --git a/doc/source/whatsnew/v0.21.0.txt b/doc/source/whatsnew/v0.21.0.txt index d48cd3668d627..8dec2c2a1188a 100644 --- a/doc/source/whatsnew/v0.21.0.txt +++ b/doc/source/whatsnew/v0.21.0.txt @@ -94,8 +94,8 @@ Bug Fixes Conversion ^^^^^^^^^^ -- Fix a bug when pd.astype() receive Series as `dtype` paramter, no action is taken. Now Series -`dtype` work the same as a `dict`. +- Fix a bug that nothing happen when `Series` is passed to pd.astype() as `dtype`. Now `Series` +works the same as a `dict` when passed to `dtype`. (:issue:`16717`). diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index f1cc969c5824a..b01c7672b6b49 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -442,8 +442,9 @@ def test_astype_str(self): expected = DataFrame(['1.12345678901']) assert_frame_equal(result, expected) - def test_astype_dict(self): - # GH7271 + @pytest.mark.parametrize("dtype_class", [dict, Series]) + def test_astype_dict_like(self, dtype_class): + # GH7271 & GH16717 a = Series(date_range('2010-01-04', periods=5)) b = Series(range(5)) c = Series([0.0, 0.2, 0.4, 0.6, 0.8]) @@ -452,7 +453,8 @@ def test_astype_dict(self): original = df.copy(deep=True) # change type of a subset of columns - result = df.astype({'b': 'str', 'd': 'float32'}) + dt1 = dtype({'b': 'str', 'd': 'float32'}) + result = df.astype(dt1) expected = DataFrame({ 'a': a, 'b': Series(['0', '1', '2', '3', '4']), @@ -461,7 +463,8 @@ def test_astype_dict(self): assert_frame_equal(result, expected) assert_frame_equal(df, original) - result = df.astype({'b': np.float32, 'c': 'float32', 'd': np.float64}) + dt2 = dtype({'b': np.float32, 'c': 'float32', 'd': np.float64}) + result = df.astype(dt2) expected = DataFrame({ 'a': a, 'b': Series([0.0, 1.0, 2.0, 3.0, 4.0], dtype='float32'), @@ -471,67 +474,23 @@ def test_astype_dict(self): assert_frame_equal(df, original) # change all columns - assert_frame_equal(df.astype({'a': str, 'b': str, 'c': str, 'd': str}), + dt3 = dtype({'a': str, 'b': str, 'c': str, 'd': str}) + assert_frame_equal(df.astype(dt3), df.astype(str)) assert_frame_equal(df, original) # error should be raised when using something other than column labels # in the keys of the dtype dict - pytest.raises(KeyError, df.astype, {'b': str, 2: str}) - pytest.raises(KeyError, df.astype, {'e': str}) + dt4 = dtype({'b': str, 2: str}) + dt5 = dtype({'e': str}) + pytest.raises(KeyError, df.astype, dt4) + pytest.raises(KeyError, df.astype, dt5) assert_frame_equal(df, original) # if the dtypes provided are the same as the original dtypes, the # resulting DataFrame should be the same as the original DataFrame - equiv = df.astype({col: df[col].dtype for col in df.columns}) - assert_frame_equal(df, equiv) - assert_frame_equal(df, original) - - def test_astype_Series(self): - # GH16717 - a = Series(date_range('2010-01-04', periods=5)) - b = Series(range(5)) - c = Series([0.0, 0.2, 0.4, 0.6, 0.8]) - d = Series(['1.0', '2', '3.14', '4', '5.4']) - df = DataFrame({'a': a, 'b': b, 'c': c, 'd': d}) - original = df.copy(deep=True) - - # change type of a subset of columns - result = df.astype(Series({'b': 'str', 'd': 'float32'})) - expected = DataFrame({ - 'a': a, - 'b': Series(['0', '1', '2', '3', '4']), - 'c': c, - 'd': Series([1.0, 2.0, 3.14, 4.0, 5.4], dtype='float32')}) - assert_frame_equal(result, expected) - assert_frame_equal(df, original) - - result = df.astype(Series( - {'b': np.float32, - 'c': 'float32', - 'd': np.float64})) - expected = DataFrame({ - 'a': a, - 'b': Series([0.0, 1.0, 2.0, 3.0, 4.0], dtype='float32'), - 'c': Series([0.0, 0.2, 0.4, 0.6, 0.8], dtype='float32'), - 'd': Series([1.0, 2.0, 3.14, 4.0, 5.4], dtype='float64')}) - assert_frame_equal(result, expected) - assert_frame_equal(df, original) - - # change all columns - result = df.astype(Series({'a': str, 'b': str, 'c': str, 'd': str})) - assert_frame_equal(result, df.astype(str)) - assert_frame_equal(df, original) - - # error should be raised when using something other than column labels - # in the keys of the dtype dict - pytest.raises(KeyError, df.astype, Series({'b': str, 2: str})) - pytest.raises(KeyError, df.astype, Series({'e': str})) - assert_frame_equal(df, original) - - # if the dtypes provided are the same as the original dtypes, the - # resulting DataFrame should be the same as the original DataFrame - equiv = df.astype(Series({col: df[col].dtype for col in df.columns})) + dt6 = dtype({col: df[col].dtype for col in df.columns}) + equiv = df.astype(dt6) assert_frame_equal(df, equiv) assert_frame_equal(df, original) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 9ab02a8c2aad7..c2630e7d10a59 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -152,24 +152,29 @@ def test_astype_unicode(self): reload(sys) # noqa sys.setdefaultencoding(former_encoding) - def test_astype_dict(self): + @pytest.mark.parametrize("dtype_class", [dict, Series]) + def run_astype_dict_like(self, dtype_class): # see gh-7271 s = Series(range(0, 10, 2), name='abc') - result = s.astype({'abc': str}) + dt1 = dtype({'abc': str}) + result = s.astype(dt1) expected = Series(['0', '2', '4', '6', '8'], name='abc') tm.assert_series_equal(result, expected) - result = s.astype({'abc': 'float64'}) + dt2 = dtype({'abc': 'float64'}) + result = s.astype(dt2) expected = Series([0.0, 2.0, 4.0, 6.0, 8.0], dtype='float64', name='abc') tm.assert_series_equal(result, expected) + dt3 = dtype({'abc': str, 'def': str}) with pytest.raises(KeyError): - s.astype({'abc': str, 'def': str}) + s.astype() + dt4 = dtype({0: str}) with pytest.raises(KeyError): - s.astype({0: str}) + s.astype(dt4) def test_astype_generic_timestamp_deprecated(self): # see gh-15524 From 930c479d10202ae2b1166aac6427ef0e86dee88f Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 10:46:38 +0800 Subject: [PATCH 3/9] Forget to align changed paramter name. --- pandas/tests/frame/test_dtypes.py | 12 ++++++------ pandas/tests/series/test_dtypes.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index b01c7672b6b49..ea7634e0b7b4a 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -453,7 +453,7 @@ def test_astype_dict_like(self, dtype_class): original = df.copy(deep=True) # change type of a subset of columns - dt1 = dtype({'b': 'str', 'd': 'float32'}) + dt1 = dtype_class({'b': 'str', 'd': 'float32'}) result = df.astype(dt1) expected = DataFrame({ 'a': a, @@ -463,7 +463,7 @@ def test_astype_dict_like(self, dtype_class): assert_frame_equal(result, expected) assert_frame_equal(df, original) - dt2 = dtype({'b': np.float32, 'c': 'float32', 'd': np.float64}) + dt2 = dtype_class({'b': np.float32, 'c': 'float32', 'd': np.float64}) result = df.astype(dt2) expected = DataFrame({ 'a': a, @@ -474,22 +474,22 @@ def test_astype_dict_like(self, dtype_class): assert_frame_equal(df, original) # change all columns - dt3 = dtype({'a': str, 'b': str, 'c': str, 'd': str}) + dt3 = dtype_class({'a': str, 'b': str, 'c': str, 'd': str}) assert_frame_equal(df.astype(dt3), df.astype(str)) assert_frame_equal(df, original) # error should be raised when using something other than column labels # in the keys of the dtype dict - dt4 = dtype({'b': str, 2: str}) - dt5 = dtype({'e': str}) + dt4 = dtype_class({'b': str, 2: str}) + dt5 = dtype_class({'e': str}) pytest.raises(KeyError, df.astype, dt4) pytest.raises(KeyError, df.astype, dt5) assert_frame_equal(df, original) # if the dtypes provided are the same as the original dtypes, the # resulting DataFrame should be the same as the original DataFrame - dt6 = dtype({col: df[col].dtype for col in df.columns}) + dt6 = dtype_class({col: df[col].dtype for col in df.columns}) equiv = df.astype(dt6) assert_frame_equal(df, equiv) assert_frame_equal(df, original) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index c2630e7d10a59..dd715c8fde194 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -157,22 +157,22 @@ def run_astype_dict_like(self, dtype_class): # see gh-7271 s = Series(range(0, 10, 2), name='abc') - dt1 = dtype({'abc': str}) + dt1 = dtype_class({'abc': str}) result = s.astype(dt1) expected = Series(['0', '2', '4', '6', '8'], name='abc') tm.assert_series_equal(result, expected) - dt2 = dtype({'abc': 'float64'}) + dt2 = dtype_class({'abc': 'float64'}) result = s.astype(dt2) expected = Series([0.0, 2.0, 4.0, 6.0, 8.0], dtype='float64', name='abc') tm.assert_series_equal(result, expected) - dt3 = dtype({'abc': str, 'def': str}) + dt3 = dtype_class({'abc': str, 'def': str}) with pytest.raises(KeyError): s.astype() - dt4 = dtype({0: str}) + dt4 = dtype_class({0: str}) with pytest.raises(KeyError): s.astype(dt4) From 342871c175c6d11e70b6de294e6b89f167d21a48 Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 11:54:32 +0800 Subject: [PATCH 4/9] An error in series/test_dtypes.py - a dtype is not used. --- pandas/tests/series/test_dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index dd715c8fde194..c3b0688deaefe 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -170,7 +170,7 @@ def run_astype_dict_like(self, dtype_class): dt3 = dtype_class({'abc': str, 'def': str}) with pytest.raises(KeyError): - s.astype() + s.astype(dt3) dt4 = dtype_class({0: str}) with pytest.raises(KeyError): From ce7e131cddef6759ace30a1a66c93613fad3fa00 Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 12:39:17 +0800 Subject: [PATCH 5/9] Change the test method to start with `test_` --- pandas/tests/series/test_dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index c3b0688deaefe..acc3987946e48 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -153,7 +153,7 @@ def test_astype_unicode(self): sys.setdefaultencoding(former_encoding) @pytest.mark.parametrize("dtype_class", [dict, Series]) - def run_astype_dict_like(self, dtype_class): + def test_astype_dict_like(self, dtype_class): # see gh-7271 s = Series(range(0, 10, 2), name='abc') From 0280e5cf29548cf277deb4bd65844c2c23059ac0 Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 15:40:18 +0800 Subject: [PATCH 6/9] When `dtype` `is_dict_like` is true, use `get()` instead of `values()` in `pd.Series.astype` --- pandas/core/generic.py | 4 ++-- pandas/tests/frame/test_dtypes.py | 7 +++++++ pandas/tests/series/test_dtypes.py | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 52ad0b2063ce7..ac629cbadaf4c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3509,10 +3509,10 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): """ if is_dict_like(dtype): if self.ndim == 1: # i.e. Series - if len(dtype) > 1 or list(dtype.keys())[0] != self.name: + if len(dtype) > 1 or self.name not in dtype.keys(): raise KeyError('Only the Series name can be used for ' 'the key in Series dtype mappings.') - new_type = list(dtype.values())[0] + new_type = dtype.get(self.name) return self.astype(new_type, copy, errors, **kwargs) elif self.ndim > 2: raise NotImplementedError( diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index ea7634e0b7b4a..57349c98bd04e 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -494,6 +494,13 @@ def test_astype_dict_like(self, dtype_class): assert_frame_equal(df, equiv) assert_frame_equal(df, original) + # if dtypes provided is empty, the resulting DataFrame + # should be the same as the original DataFrame + dt7 = dtype_class({}) + equiv = df.astype(dt7) + assert_frame_equal(df, equiv) + assert_frame_equal(df, original) + def test_astype_duplicate_col(self): a1 = Series([1, 2, 3, 4, 5], name='a') b = Series([0.1, 0.2, 0.4, 0.6, 0.8], name='b') diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index acc3987946e48..5093f031f3fe5 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -176,6 +176,11 @@ def test_astype_dict_like(self, dtype_class): with pytest.raises(KeyError): s.astype(dt4) + # if dtypes provided is empty, it should error + dt5 = dtype_class({}) + with pytest.raises(KeyError): + s.astype(dt5) + def test_astype_generic_timestamp_deprecated(self): # see gh-15524 data = [1] From 7d889203fb919c6fa229a01479de77f575b29d20 Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Tue, 20 Jun 2017 19:56:10 +0800 Subject: [PATCH 7/9] Move to v0.20.3, and some minor changes. --- doc/source/whatsnew/v0.20.3.txt | 1 + doc/source/whatsnew/v0.21.0.txt | 2 -- pandas/core/generic.py | 4 ++-- pandas/tests/frame/test_dtypes.py | 3 ++- pandas/tests/series/test_dtypes.py | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index ebbdecb7dc0d0..454259dbcbfd9 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -47,6 +47,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 construction when passing a Series with ``dtype='category'`` (:issue:`16524`). +- Bug in pd.astype() when passing `Series` as `dtype`. (:issue:`16717`). Indexing ^^^^^^^^ diff --git a/doc/source/whatsnew/v0.21.0.txt b/doc/source/whatsnew/v0.21.0.txt index 8dec2c2a1188a..de2516d75040b 100644 --- a/doc/source/whatsnew/v0.21.0.txt +++ b/doc/source/whatsnew/v0.21.0.txt @@ -94,8 +94,6 @@ Bug Fixes Conversion ^^^^^^^^^^ -- Fix a bug that nothing happen when `Series` is passed to pd.astype() as `dtype`. Now `Series` -works the same as a `dict` when passed to `dtype`. (:issue:`16717`). diff --git a/pandas/core/generic.py b/pandas/core/generic.py index ac629cbadaf4c..4d4297d41c2aa 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3509,10 +3509,10 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): """ if is_dict_like(dtype): if self.ndim == 1: # i.e. Series - if len(dtype) > 1 or self.name not in dtype.keys(): + if len(dtype) > 1 or self.name not in dtype: raise KeyError('Only the Series name can be used for ' 'the key in Series dtype mappings.') - new_type = dtype.get(self.name) + new_type = dtype[self.name] return self.astype(new_type, copy, errors, **kwargs) elif self.ndim > 2: raise NotImplementedError( diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index 57349c98bd04e..335b76ff2aade 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -494,10 +494,11 @@ def test_astype_dict_like(self, dtype_class): assert_frame_equal(df, equiv) assert_frame_equal(df, original) + # GH 16717 # if dtypes provided is empty, the resulting DataFrame # should be the same as the original DataFrame dt7 = dtype_class({}) - equiv = df.astype(dt7) + result = df.astype(dt7) assert_frame_equal(df, equiv) assert_frame_equal(df, original) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 5093f031f3fe5..2ec579842e33f 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -176,6 +176,7 @@ def test_astype_dict_like(self, dtype_class): with pytest.raises(KeyError): s.astype(dt4) + # GH16717 # if dtypes provided is empty, it should error dt5 = dtype_class({}) with pytest.raises(KeyError): From 08eabd9acc0e39790ab559bdf4d0dfdb74f6ad4c Mon Sep 17 00:00:00 2001 From: Bran Yang Date: Wed, 28 Jun 2017 20:48:10 +0800 Subject: [PATCH 8/9] Change the whatsnew. --- 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 454259dbcbfd9..fc59db3a403f9 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -47,7 +47,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 construction when passing a Series with ``dtype='category'`` (:issue:`16524`). -- Bug in pd.astype() when passing `Series` as `dtype`. (:issue:`16717`). +- Bug in `.astype()` when passing a `Series` to `dtype`. (:issue:`16717`). Indexing ^^^^^^^^ From fbd0755c3cecd973c400686b2a0a1cb468bd96ad Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 30 Jun 2017 23:09:02 +0300 Subject: [PATCH 9/9] update whatsnew --- doc/source/whatsnew/v0.20.3.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index fc59db3a403f9..8997d68c65615 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -46,8 +46,8 @@ 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 construction when passing a Series with ``dtype='category'`` (:issue:`16524`). -- Bug in `.astype()` when passing a `Series` to `dtype`. (:issue:`16717`). +- Bug in ``Series`` construction when passing a ``Series`` with ``dtype='category'`` (:issue:`16524`). +- Bug in ``DataFrame.astype()`` when passing a ``Series`` as the ``dtype`` kwarg. (:issue:`16717`). Indexing ^^^^^^^^