From 091af83e8a635c59a8ee72c78c595e439b2e8930 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sat, 9 Jul 2016 17:50:25 -0400 Subject: [PATCH] CLN: Removed coerce param in pd.to_timedelta [ci skip] --- doc/source/whatsnew/v0.20.0.txt | 1 + pandas/tseries/tests/test_timeseries.py | 16 ---------------- pandas/tseries/timedeltas.py | 5 +---- pandas/tseries/tools.py | 5 +---- 4 files changed, 3 insertions(+), 24 deletions(-) diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index 0354a8046e873..7fa9991138fba 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -62,6 +62,7 @@ Deprecations Removal of prior version deprecations/changes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`) diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py index ac48fcc2551ea..f640b3974b360 100644 --- a/pandas/tseries/tests/test_timeseries.py +++ b/pandas/tseries/tests/test_timeseries.py @@ -5514,22 +5514,6 @@ def test_second(self): class TestDaysInMonth(tm.TestCase): - def test_coerce_deprecation(self): - - # deprecation of coerce - with tm.assert_produces_warning(FutureWarning): - to_datetime('2015-02-29', coerce=True) - with tm.assert_produces_warning(FutureWarning): - self.assertRaises(ValueError, - lambda: to_datetime('2015-02-29', coerce=False)) - - # multiple arguments - for e, c in zip(['raise', 'ignore', 'coerce'], [True, False]): - with tm.assert_produces_warning(FutureWarning): - self.assertRaises(TypeError, - lambda: to_datetime('2015-02-29', errors=e, - coerce=c)) - # tests for issue #10154 def test_day_not_in_month_coerce(self): self.assertTrue(isnull(to_datetime('2015-02-29', errors='coerce'))) diff --git a/pandas/tseries/timedeltas.py b/pandas/tseries/timedeltas.py index 2ca3fcea8005b..9bf39652a4e00 100644 --- a/pandas/tseries/timedeltas.py +++ b/pandas/tseries/timedeltas.py @@ -11,12 +11,9 @@ is_timedelta64_dtype, is_list_like) from pandas.types.generic import ABCSeries, ABCIndexClass -from pandas.util.decorators import deprecate_kwarg -@deprecate_kwarg(old_arg_name='coerce', new_arg_name='errors', - mapping={True: 'coerce', False: 'raise'}) -def to_timedelta(arg, unit='ns', box=True, errors='raise', coerce=None): +def to_timedelta(arg, unit='ns', box=True, errors='raise'): """ Convert argument to timedelta diff --git a/pandas/tseries/tools.py b/pandas/tseries/tools.py index 93d35ff964e69..637e70b76de98 100644 --- a/pandas/tseries/tools.py +++ b/pandas/tseries/tools.py @@ -16,7 +16,6 @@ from pandas.types.missing import notnull import pandas.compat as compat -from pandas.util.decorators import deprecate_kwarg _DATEUTIL_LEXER_SPLIT = None try: @@ -175,10 +174,8 @@ def _guess_datetime_format_for_array(arr, **kwargs): return _guess_datetime_format(arr[non_nan_elements[0]], **kwargs) -@deprecate_kwarg(old_arg_name='coerce', new_arg_name='errors', - mapping={True: 'coerce', False: 'raise'}) def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False, - utc=None, box=True, format=None, exact=True, coerce=None, + utc=None, box=True, format=None, exact=True, unit=None, infer_datetime_format=False): """ Convert argument to datetime.