Skip to content

Commit d62170f

Browse files
author
Chris Bertinato
committed
Fixes
1 parent 291d30f commit d62170f

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

doc/source/whatsnew/v0.24.0.rst

-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,6 @@ Deprecations
13261326
- Passing an integer to :meth:`Series.fillna` and :meth:`DataFrame.fillna` with ``timedelta64[ns]`` dtypes is deprecated, will raise ``TypeError`` in a future version. Use ``obj.fillna(pd.Timedelta(...))`` instead (:issue:`24694`)
13271327
- ``Series.cat.categorical``, ``Series.cat.name`` and ``Sersies.cat.index`` have been deprecated. Use the attributes on ``Series.cat`` or ``Series`` directly. (:issue:`24751`).
13281328
- Passing a dtype without a precision like ``np.dtype('datetime64')`` or ``timedelta64`` to :class:`Index`, :class:`DatetimeIndex` and :class:`TimedeltaIndex` is now deprecated. Use the nanosecond-precision dtype instead (:issue:`24753`).
1329-
- The functions :func:`pandas.to_datetime` and :func:`pandas.to_timedelta` have deprecated the ``box`` keyword. Use :attr:`Series.values` and :meth:`Timestamp.to_datetime64`/:meth:`Timedelta.to_timedelta64` instead to get an ndarray of values or ``numpy.timestamp64``/``numpy.timedelta64``, respectively (:issue:`24416`).
13301329

13311330
.. _whatsnew_0240.deprecations.datetimelike_int_ops:
13321331

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Deprecations
7979
~~~~~~~~~~~~
8080

8181
- Deprecated the `M (months)` and `Y (year)` `units` parameter of :func: `pandas.to_timedelta`, :func: `pandas.Timedelta` and :func: `pandas.TimedeltaIndex` (:issue:`16344`)
82+
- The functions :func:`pandas.to_datetime` and :func:`pandas.to_timedelta` have deprecated the ``box`` keyword. Use :attr:`Series.values` and :meth:`Timestamp.to_datetime64`/:meth:`Timedelta.to_timedelta64` instead to get an ndarray of values or ``numpy.timestamp64``/``numpy.timedelta64``, respectively (:issue:`24416`)
8283

8384
.. _whatsnew_0250.prior_deprecations:
8485

pandas/core/indexes/datetimelike.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,7 @@ def asobject(self):
300300
return self.astype(object)
301301

302302
def _convert_tolerance(self, tolerance, target):
303-
tolerance = to_timedelta(tolerance)
304-
if isinstance(tolerance, ABCIndexClass):
305-
tolerance = tolerance.to_numpy()
306-
else:
307-
tolerance = np.asarray(tolerance.to_timedelta64())
303+
tolerance = np.asarray(to_timedelta(tolerance).to_numpy())
308304

309305
if target.size != tolerance.size and tolerance.size > 1:
310306
raise ValueError('list-like tolerance size must match '

pandas/tests/indexes/datetimes/test_tools.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1215,11 +1215,15 @@ def test_to_datetime_types(self, cache):
12151215
def test_to_datetime_unprocessable_input(self, cache, box, klass):
12161216
# GH 4928
12171217
# GH 21864
1218-
result = to_datetime([1, '1'], errors='ignore', cache=cache, box=box)
1218+
with tm.assert_produces_warning(FutureWarning):
1219+
result = to_datetime([1, '1'], errors='ignore', cache=cache,
1220+
box=box)
1221+
12191222
expected = klass(np.array([1, '1'], dtype='O'))
12201223
tm.assert_equal(result, expected)
12211224
msg = "invalid string coercion to datetime"
1222-
with pytest.raises(TypeError, match=msg):
1225+
with pytest.raises(TypeError, match=msg), \
1226+
tm.assert_produces_warning(FutureWarning):
12231227
to_datetime([1, '1'], errors='raise', cache=cache, box=box)
12241228

12251229
def test_to_datetime_other_datetime64_units(self):

pandas/tests/scalar/timedelta/test_timedelta.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ def test_iso_conversion(self):
310310
assert to_timedelta('P0DT0H0M1S') == expected
311311

312312
def test_nat_converters(self):
313-
result = to_timedelta('nat', box=False)
314-
assert result.dtype.kind == 'm'
313+
result = to_timedelta('nat').to_numpy()
314+
assert result.dtype.kind == 'M'
315315
assert result.astype('int64') == iNaT
316316

317-
result = to_timedelta('nan', box=False)
318-
assert result.dtype.kind == 'm'
317+
result = to_timedelta('nan').to_numpy()
318+
assert result.dtype.kind == 'M'
319319
assert result.astype('int64') == iNaT
320320

321321
@pytest.mark.filterwarnings("ignore:M and Y units are deprecated")

0 commit comments

Comments
 (0)