From 6fb1cec49a832354e78a78c313d767d562cad8f3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Fri, 26 Oct 2018 22:50:37 -0700 Subject: [PATCH] CLN: Rename raise_on_error to errors for .dtype 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 768868d585721..1056d200a7e63 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -948,6 +948,7 @@ Removal of prior version deprecations/changes - Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`) - :meth:`SparseArray.get_values` and :meth:`SparseArray.to_dense` have dropped the ``fill`` parameter (:issue:`14686`) - :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 a80b6df703df0..e6a97ec7f530a 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 @@ -5148,8 +5147,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``. @@ -5173,9 +5170,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):