Skip to content

Commit 750b6ae

Browse files
gfyoungjorisvandenbossche
authored andcommitted
CLN: Removed coerce param in pd.to_timedelta and pd.to_datetime
Deprecated back in `v0.17.0` <a href="https://github.com/pydata/pandas /commit/987b7e7e586b8df1d127406c69e0a9094a1a5322">here</a>. Seems appropriate to carry though now. Author: gfyoung <[email protected]> Closes #13602 from gfyoung/remove-coerce-to-timedelta and squashes the following commits: 091af83 [gfyoung] CLN: Removed coerce param in pd.to_timedelta
1 parent 6a3755b commit 750b6ae

File tree

4 files changed

+3
-24
lines changed

4 files changed

+3
-24
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Deprecations
6262
Removal of prior version deprecations/changes
6363
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6464

65+
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
6566

6667

6768

pandas/tseries/tests/test_timeseries.py

-16
Original file line numberDiff line numberDiff line change
@@ -5514,22 +5514,6 @@ def test_second(self):
55145514

55155515

55165516
class TestDaysInMonth(tm.TestCase):
5517-
def test_coerce_deprecation(self):
5518-
5519-
# deprecation of coerce
5520-
with tm.assert_produces_warning(FutureWarning):
5521-
to_datetime('2015-02-29', coerce=True)
5522-
with tm.assert_produces_warning(FutureWarning):
5523-
self.assertRaises(ValueError,
5524-
lambda: to_datetime('2015-02-29', coerce=False))
5525-
5526-
# multiple arguments
5527-
for e, c in zip(['raise', 'ignore', 'coerce'], [True, False]):
5528-
with tm.assert_produces_warning(FutureWarning):
5529-
self.assertRaises(TypeError,
5530-
lambda: to_datetime('2015-02-29', errors=e,
5531-
coerce=c))
5532-
55335517
# tests for issue #10154
55345518
def test_day_not_in_month_coerce(self):
55355519
self.assertTrue(isnull(to_datetime('2015-02-29', errors='coerce')))

pandas/tseries/timedeltas.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111
is_timedelta64_dtype,
1212
is_list_like)
1313
from pandas.types.generic import ABCSeries, ABCIndexClass
14-
from pandas.util.decorators import deprecate_kwarg
1514

1615

17-
@deprecate_kwarg(old_arg_name='coerce', new_arg_name='errors',
18-
mapping={True: 'coerce', False: 'raise'})
19-
def to_timedelta(arg, unit='ns', box=True, errors='raise', coerce=None):
16+
def to_timedelta(arg, unit='ns', box=True, errors='raise'):
2017
"""
2118
Convert argument to timedelta
2219

pandas/tseries/tools.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from pandas.types.missing import notnull
1717

1818
import pandas.compat as compat
19-
from pandas.util.decorators import deprecate_kwarg
2019

2120
_DATEUTIL_LEXER_SPLIT = None
2221
try:
@@ -175,10 +174,8 @@ def _guess_datetime_format_for_array(arr, **kwargs):
175174
return _guess_datetime_format(arr[non_nan_elements[0]], **kwargs)
176175

177176

178-
@deprecate_kwarg(old_arg_name='coerce', new_arg_name='errors',
179-
mapping={True: 'coerce', False: 'raise'})
180177
def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
181-
utc=None, box=True, format=None, exact=True, coerce=None,
178+
utc=None, box=True, format=None, exact=True,
182179
unit=None, infer_datetime_format=False):
183180
"""
184181
Convert argument to datetime.

0 commit comments

Comments
 (0)