Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Bertinato committed Feb 25, 2019
1 parent 291d30f commit d62170f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,6 @@ Deprecations
- 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`)
- ``Series.cat.categorical``, ``Series.cat.name`` and ``Sersies.cat.index`` have been deprecated. Use the attributes on ``Series.cat`` or ``Series`` directly. (:issue:`24751`).
- 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`).
- 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`).

.. _whatsnew_0240.deprecations.datetimelike_int_ops:

Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Deprecations
~~~~~~~~~~~~

- Deprecated the `M (months)` and `Y (year)` `units` parameter of :func: `pandas.to_timedelta`, :func: `pandas.Timedelta` and :func: `pandas.TimedeltaIndex` (:issue:`16344`)
- 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`)

.. _whatsnew_0250.prior_deprecations:

Expand Down
6 changes: 1 addition & 5 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,7 @@ def asobject(self):
return self.astype(object)

def _convert_tolerance(self, tolerance, target):
tolerance = to_timedelta(tolerance)
if isinstance(tolerance, ABCIndexClass):
tolerance = tolerance.to_numpy()
else:
tolerance = np.asarray(tolerance.to_timedelta64())
tolerance = np.asarray(to_timedelta(tolerance).to_numpy())

if target.size != tolerance.size and tolerance.size > 1:
raise ValueError('list-like tolerance size must match '
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,11 +1215,15 @@ def test_to_datetime_types(self, cache):
def test_to_datetime_unprocessable_input(self, cache, box, klass):
# GH 4928
# GH 21864
result = to_datetime([1, '1'], errors='ignore', cache=cache, box=box)
with tm.assert_produces_warning(FutureWarning):
result = to_datetime([1, '1'], errors='ignore', cache=cache,
box=box)

expected = klass(np.array([1, '1'], dtype='O'))
tm.assert_equal(result, expected)
msg = "invalid string coercion to datetime"
with pytest.raises(TypeError, match=msg):
with pytest.raises(TypeError, match=msg), \
tm.assert_produces_warning(FutureWarning):
to_datetime([1, '1'], errors='raise', cache=cache, box=box)

def test_to_datetime_other_datetime64_units(self):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/scalar/timedelta/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ def test_iso_conversion(self):
assert to_timedelta('P0DT0H0M1S') == expected

def test_nat_converters(self):
result = to_timedelta('nat', box=False)
assert result.dtype.kind == 'm'
result = to_timedelta('nat').to_numpy()
assert result.dtype.kind == 'M'
assert result.astype('int64') == iNaT

result = to_timedelta('nan', box=False)
assert result.dtype.kind == 'm'
result = to_timedelta('nan').to_numpy()
assert result.dtype.kind == 'M'
assert result.astype('int64') == iNaT

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

0 comments on commit d62170f

Please sign in to comment.