From 020782a0c79ca7500f6ad2f5950cd9ebb63611c1 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sat, 27 Oct 2018 19:44:15 -0700 Subject: [PATCH] CLN: Rename raise_on_error to errors for .dtype (#23374) xref gh-14967. --- doc/source/whatsnew/v0.24.0.txt | 1 + pandas/core/generic.py | 8 +------- pandas/tests/frame/test_dtypes.py | 3 --- pandas/tests/series/test_dtypes.py | 3 --- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 5b3d9660bce64..70725a347c9d0 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -953,6 +953,7 @@ Removal of prior version deprecations/changes - :meth:`SparseArray.get_values` and :meth:`SparseArray.to_dense` have dropped the ``fill`` parameter (:issue:`14686`) - :meth:`DataFrame.sortlevel` and :meth:`Series.sortlevel` have been removed (:issue:`15099`) - :meth:`SparseSeries.to_dense` has dropped the ``sparse_only`` parameter (:issue:`14686`) +- :meth:`DataFrame.astype` and :meth:`Series.astype` have renamed the ``raise_on_error`` argument to ``errors`` (:issue:`14967`) .. _whatsnew_0240.performance: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 44497c5dcb377..693cd14c8ca1d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -53,8 +53,7 @@ isidentifier, set_function_name, cPickle as pkl) from pandas.core.ops import _align_method_FRAME import pandas.core.nanops as nanops -from pandas.util._decorators import (Appender, Substitution, - deprecate_kwarg) +from pandas.util._decorators import Appender, Substitution from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs from pandas.core import config @@ -5136,8 +5135,6 @@ def _to_dict_of_blocks(self, copy=True): return {k: self._constructor(v).__finalize__(self) for k, v, in self._data.to_dict(copy=copy).items()} - @deprecate_kwarg(old_arg_name='raise_on_error', new_arg_name='errors', - mapping={True: 'raise', False: 'ignore'}) def astype(self, dtype, copy=True, errors='raise', **kwargs): """ Cast a pandas object to a specified dtype ``dtype``. @@ -5161,9 +5158,6 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): .. versionadded:: 0.20.0 - raise_on_error : raise on invalid input - .. deprecated:: 0.20.0 - Use ``errors`` instead kwargs : keyword arguments to pass on to the constructor Returns diff --git a/pandas/tests/frame/test_dtypes.py b/pandas/tests/frame/test_dtypes.py index 2afaeea3755d0..2dbf3e9784749 100644 --- a/pandas/tests/frame/test_dtypes.py +++ b/pandas/tests/frame/test_dtypes.py @@ -830,9 +830,6 @@ def test_arg_for_errors_in_astype(self): with pytest.raises(ValueError): df.astype(np.float64, errors=True) - with tm.assert_produces_warning(FutureWarning): - df.astype(np.int8, raise_on_error=False) - df.astype(np.int8, errors='ignore') @pytest.mark.parametrize('input_vals', [ diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 55a1afcb504e7..a0058bc42cefb 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -454,9 +454,6 @@ def test_arg_for_errors_in_astype(self): with pytest.raises(ValueError): s.astype(np.float64, errors=False) - with tm.assert_produces_warning(FutureWarning): - s.astype(np.int8, raise_on_error=True) - s.astype(np.int8, errors='raise') def test_intercept_astype_object(self):