From 48cb3946bd89ec04bd3c72c3d0938cc729e16112 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Sun, 18 Feb 2018 15:54:49 -0800 Subject: [PATCH 1/5] implement Timedelta.__mod__ etc, test but do _not_ fix related bugs --- doc/source/timedeltas.rst | 12 ++ doc/source/whatsnew/v0.23.0.txt | 13 ++ pandas/_libs/tslibs/timedeltas.pyx | 18 +++ pandas/tests/scalar/test_timedelta.py | 180 ++++++++++++++++++++++++++ 4 files changed, 223 insertions(+) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 50cff4c7bbdfb..9890c976c4e5a 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -283,6 +283,18 @@ Rounded division (floor-division) of a ``timedelta64[ns]`` Series by a scalar td // pd.Timedelta(days=3, hours=4) pd.Timedelta(days=3, hours=4) // td +The mod (%) and divmod operations are defined for ``Timedelta`` when operating with another timedelta-like or with a numeric argument. (:issue:`19365`) + +.. ipython:: python + + pd.Timedelta(hours=37) % datetime.timedelta(hours=2) + + # divmod against a timedelta-like returns a pair (int, Timedelta) + divmod(datetime.timedelta(hours=2), pd.Timedelta(minutes=11)) + + # divmod against a numeric returns a pair (Timedelta, Timedelta) + divmod(pd.Timedelta(hours=25), 86400000000000) + Attributes ---------- diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 11c49995372f5..d3565be6312f1 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -117,6 +117,18 @@ resetting indexes. See the :ref:`Sorting by Indexes and Values # Sort by 'second' (index) and 'A' (column) df_multi.sort_values(by=['second', 'A']) +.. _whatsnew_0230.enhancements.timedelta_mod + +Timedelta mod method +^^^^^^^^^^^^^^^^^^^^ + +``mod`` (%) and ``divmod`` operations are now defined on ``Timedelta`` objects when operating with either timedelta-like or with numeric arguments. (:issue:`19365`) + +.. ipython:: python + + td = pd.Timedelta(hours=37) + td + .. _whatsnew_0230.enhancements.ran_inf: ``.rank()`` handles ``inf`` values when ``NaN`` are present @@ -571,6 +583,7 @@ Other API Changes - Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`) - :class:`DateOffset` objects render more simply, e.g. "" instead of "" (:issue:`19403`) - :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`) +- :func:`Timedelta.__mod__`, :func:`Timedelta.__divmod__` now accept timedelta-like and numeric arguments instead of raising ``TypeError`` (:issue:`19365`) .. _whatsnew_0230.deprecations: diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 37693068e0974..f10175fddd00b 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1149,6 +1149,24 @@ class Timedelta(_Timedelta): return np.nan return other.value // self.value + def __mod__(self, other): + # Naive implementation, room for optimization + return self.__divmod__(other)[1] + + def __rmod__(self, other): + # Naive implementation, room for optimization + return self.__rdivmod__(other)[1] + + def __divmod__(self, other): + # Naive implementation, room for optimization + div = self // other + return div, self - div * other + + def __rdivmod__(self, other): + # Naive implementation, room for optimization + div = other // self + return div, other - div * self + cdef _floordiv(int64_t value, right): return value // right diff --git a/pandas/tests/scalar/test_timedelta.py b/pandas/tests/scalar/test_timedelta.py index 667266be2a89b..6ac9514b18a1f 100644 --- a/pandas/tests/scalar/test_timedelta.py +++ b/pandas/tests/scalar/test_timedelta.py @@ -254,6 +254,186 @@ def test_rfloordiv(self): with pytest.raises(TypeError): ser // td + def test_td_mod_timedeltalike(self): + # GH#19365 + td = Timedelta(hours=37) + + # Timedelta-like others + result = td % Timedelta(hours=6) + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=1) + + result = td % timedelta(minutes=60) + assert isinstance(result, Timedelta) + assert result == Timedelta(0) + + result = td % NaT + assert result is NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') + def test_td_mod_timedelta64_nat(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % np.timedelta64('NaT', 'ns') + assert result is NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') + def test_td_mod_timedelta64(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % np.timedelta64(2, 'h') + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=1) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_td_mod_offset(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % pd.offsets.Hour(5) + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=2) + + def test_td_mod_numeric(self): + # GH#19365 + td = Timedelta(hours=37) + + # Numeric Others + result = td % 2 + assert isinstance(result, Timedelta) + assert result == Timedelta(0) + + result = td % 1e12 + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=3, seconds=20) + + result = td % int(1e12) + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=3, seconds=20) + + def test_td_mod_invalid(self): + # GH#19365 + td = Timedelta(hours=37) + + with pytest.raises(TypeError): + td % pd.Timestamp('2018-01-22') + + with pytest.raises(TypeError): + td % [] + + def test_td_rmod_pytimedelta(self): + # GH#19365 + td = Timedelta(minutes=3) + + result = timedelta(minutes=4) % td + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=1) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_td_rmod_timedelta64(self): + # GH#19365 + td = Timedelta(minutes=3) + result = np.timedelta64(5, 'm') % td + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=2) + + def test_td_rmod_invalid(self): + # GH#19365 + td = Timedelta(minutes=3) + + with pytest.raises(TypeError): + pd.Timestamp('2018-01-22') % td + + with pytest.raises(TypeError): + 15 % td + + with pytest.raises(TypeError): + 16.0 % td + + with pytest.raises(TypeError): + np.array([22, 24]) % td + + def test_td_divmod_numeric(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, 53 * 3600 * 1e9) + assert result[0] == Timedelta(1, unit='ns') + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=1) + + assert result + result = divmod(td, np.nan) + assert result[0] is pd.NaT + assert result[1] is pd.NaT + + def test_td_divmod(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, timedelta(days=1)) + assert result[0] == 2 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=6) + + result = divmod(td, 54) + assert result[0] == Timedelta(hours=1) + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(0) + + result = divmod(td, pd.NaT) + assert np.isnan(result[0]) + assert result[1] is pd.NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_td_divmod_offset(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, pd.offsets.Hour(-4)) + assert result[0] == -14 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=-2) + + def test_td_divmod_invalid(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + with pytest.raises(TypeError): + divmod(td, pd.Timestamp('2018-01-22')) + + def test_td_rdivmod_pytimedelta(self): + # GH#19365 + result = divmod(timedelta(days=2, hours=6), Timedelta(days=1)) + assert result[0] == 2 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=6) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_td_rdivmod_offset(self): + result = divmod(pd.offsets.Hour(54), Timedelta(hours=-4)) + assert result[0] == -14 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=-2) + + def test_td_rdivmod_invalid(self): + # GH#19365 + td = Timedelta(minutes=3) + + with pytest.raises(TypeError): + divmod(pd.Timestamp('2018-01-22'), td) + + with pytest.raises(TypeError): + divmod(15, td) + + with pytest.raises(TypeError): + divmod(16.0, td) + + with pytest.raises(TypeError): + divmod(np.array([22, 24]), td) + class TestTimedeltaComparison(object): def test_comparison_object_array(self): From 5782463a9d2e68f132d3c02e548e67b6ab9dcbcd Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Sun, 18 Feb 2018 16:03:47 -0800 Subject: [PATCH 2/5] try to reference doc section --- doc/source/timedeltas.rst | 2 ++ doc/source/whatsnew/v0.23.0.txt | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 9890c976c4e5a..93b144d31c788 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -283,6 +283,8 @@ Rounded division (floor-division) of a ``timedelta64[ns]`` Series by a scalar td // pd.Timedelta(days=3, hours=4) pd.Timedelta(days=3, hours=4) // td +.. _timedeltas.mod_divmod: + The mod (%) and divmod operations are defined for ``Timedelta`` when operating with another timedelta-like or with a numeric argument. (:issue:`19365`) .. ipython:: python diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index d3565be6312f1..5c294022647a4 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -122,12 +122,14 @@ resetting indexes. See the :ref:`Sorting by Indexes and Values Timedelta mod method ^^^^^^^^^^^^^^^^^^^^ -``mod`` (%) and ``divmod`` operations are now defined on ``Timedelta`` objects when operating with either timedelta-like or with numeric arguments. (:issue:`19365`) +``mod`` (%) and ``divmod`` operations are now defined on ``Timedelta`` objects +when operating with either timedelta-like or with numeric arguments. +See the :ref:`<_timedeltas.mod_divmod>` documentation section. (:issue:`19365`) .. ipython:: python td = pd.Timedelta(hours=37) - td + td % pd.Timedelta(minutes=45) .. _whatsnew_0230.enhancements.ran_inf: From c252eff80414a56f44cb8df7d45704066a47f5ee Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 19 Feb 2018 09:18:22 -0800 Subject: [PATCH 3/5] move tests to test_arithmetic --- .../tests/scalar/timedelta/test_arithmetic.py | 186 ++++++++++++++++++ .../tests/scalar/timedelta/test_timedelta.py | 180 ----------------- 2 files changed, 186 insertions(+), 180 deletions(-) diff --git a/pandas/tests/scalar/timedelta/test_arithmetic.py b/pandas/tests/scalar/timedelta/test_arithmetic.py index 90c911c24f6a9..43e9491b9de0b 100644 --- a/pandas/tests/scalar/timedelta/test_arithmetic.py +++ b/pandas/tests/scalar/timedelta/test_arithmetic.py @@ -420,3 +420,189 @@ def test_td_rfloordiv_numeric_series(self): assert res is NotImplemented with pytest.raises(TypeError): ser // td + + def test_mod_timedeltalike(self): + # GH#19365 + td = Timedelta(hours=37) + + # Timedelta-like others + result = td % Timedelta(hours=6) + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=1) + + result = td % timedelta(minutes=60) + assert isinstance(result, Timedelta) + assert result == Timedelta(0) + + result = td % NaT + assert result is NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') + def test_mod_timedelta64_nat(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % np.timedelta64('NaT', 'ns') + assert result is NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') + def test_mod_timedelta64(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % np.timedelta64(2, 'h') + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=1) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_mod_offset(self): + # GH#19365 + td = Timedelta(hours=37) + + result = td % pd.offsets.Hour(5) + assert isinstance(result, Timedelta) + assert result == Timedelta(hours=2) + + # ---------------------------------------------------------------- + # Timedelta.__mod__, __rmod__ + + def test_mod_numeric(self): + # GH#19365 + td = Timedelta(hours=37) + + # Numeric Others + result = td % 2 + assert isinstance(result, Timedelta) + assert result == Timedelta(0) + + result = td % 1e12 + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=3, seconds=20) + + result = td % int(1e12) + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=3, seconds=20) + + def test_mod_invalid(self): + # GH#19365 + td = Timedelta(hours=37) + + with pytest.raises(TypeError): + td % pd.Timestamp('2018-01-22') + + with pytest.raises(TypeError): + td % [] + + def test_rmod_pytimedelta(self): + # GH#19365 + td = Timedelta(minutes=3) + + result = timedelta(minutes=4) % td + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=1) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_rmod_timedelta64(self): + # GH#19365 + td = Timedelta(minutes=3) + result = np.timedelta64(5, 'm') % td + assert isinstance(result, Timedelta) + assert result == Timedelta(minutes=2) + + def test_rmod_invalid(self): + # GH#19365 + td = Timedelta(minutes=3) + + with pytest.raises(TypeError): + pd.Timestamp('2018-01-22') % td + + with pytest.raises(TypeError): + 15 % td + + with pytest.raises(TypeError): + 16.0 % td + + with pytest.raises(TypeError): + np.array([22, 24]) % td + + # ---------------------------------------------------------------- + # Timedelta.__divmod__, __rdivmod__ + + def test_divmod_numeric(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, 53 * 3600 * 1e9) + assert result[0] == Timedelta(1, unit='ns') + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=1) + + assert result + result = divmod(td, np.nan) + assert result[0] is pd.NaT + assert result[1] is pd.NaT + + def test_divmod(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, timedelta(days=1)) + assert result[0] == 2 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=6) + + result = divmod(td, 54) + assert result[0] == Timedelta(hours=1) + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(0) + + result = divmod(td, pd.NaT) + assert np.isnan(result[0]) + assert result[1] is pd.NaT + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_divmod_offset(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + result = divmod(td, pd.offsets.Hour(-4)) + assert result[0] == -14 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=-2) + + def test_divmod_invalid(self): + # GH#19365 + td = Timedelta(days=2, hours=6) + + with pytest.raises(TypeError): + divmod(td, pd.Timestamp('2018-01-22')) + + def test_rdivmod_pytimedelta(self): + # GH#19365 + result = divmod(timedelta(days=2, hours=6), Timedelta(days=1)) + assert result[0] == 2 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=6) + + @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') + def test_rdivmod_offset(self): + result = divmod(pd.offsets.Hour(54), Timedelta(hours=-4)) + assert result[0] == -14 + assert isinstance(result[1], Timedelta) + assert result[1] == Timedelta(hours=-2) + + def test_rdivmod_invalid(self): + # GH#19365 + td = Timedelta(minutes=3) + + with pytest.raises(TypeError): + divmod(pd.Timestamp('2018-01-22'), td) + + with pytest.raises(TypeError): + divmod(15, td) + + with pytest.raises(TypeError): + divmod(16.0, td) + + with pytest.raises(TypeError): + divmod(np.array([22, 24]), td) diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py index eab5317b57e98..420b66b4ce0dc 100644 --- a/pandas/tests/scalar/timedelta/test_timedelta.py +++ b/pandas/tests/scalar/timedelta/test_timedelta.py @@ -92,186 +92,6 @@ def test_binary_ops_nat(self): # FIXME: The next test is wrong: td * NaT should raise assert (td * pd.NaT) is pd.NaT - def test_td_mod_timedeltalike(self): - # GH#19365 - td = Timedelta(hours=37) - - # Timedelta-like others - result = td % Timedelta(hours=6) - assert isinstance(result, Timedelta) - assert result == Timedelta(hours=1) - - result = td % timedelta(minutes=60) - assert isinstance(result, Timedelta) - assert result == Timedelta(0) - - result = td % NaT - assert result is NaT - - @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') - def test_td_mod_timedelta64_nat(self): - # GH#19365 - td = Timedelta(hours=37) - - result = td % np.timedelta64('NaT', 'ns') - assert result is NaT - - @pytest.mark.xfail(reason='GH#19378 floordiv td64 returns td64') - def test_td_mod_timedelta64(self): - # GH#19365 - td = Timedelta(hours=37) - - result = td % np.timedelta64(2, 'h') - assert isinstance(result, Timedelta) - assert result == Timedelta(hours=1) - - @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') - def test_td_mod_offset(self): - # GH#19365 - td = Timedelta(hours=37) - - result = td % pd.offsets.Hour(5) - assert isinstance(result, Timedelta) - assert result == Timedelta(hours=2) - - def test_td_mod_numeric(self): - # GH#19365 - td = Timedelta(hours=37) - - # Numeric Others - result = td % 2 - assert isinstance(result, Timedelta) - assert result == Timedelta(0) - - result = td % 1e12 - assert isinstance(result, Timedelta) - assert result == Timedelta(minutes=3, seconds=20) - - result = td % int(1e12) - assert isinstance(result, Timedelta) - assert result == Timedelta(minutes=3, seconds=20) - - def test_td_mod_invalid(self): - # GH#19365 - td = Timedelta(hours=37) - - with pytest.raises(TypeError): - td % pd.Timestamp('2018-01-22') - - with pytest.raises(TypeError): - td % [] - - def test_td_rmod_pytimedelta(self): - # GH#19365 - td = Timedelta(minutes=3) - - result = timedelta(minutes=4) % td - assert isinstance(result, Timedelta) - assert result == Timedelta(minutes=1) - - @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') - def test_td_rmod_timedelta64(self): - # GH#19365 - td = Timedelta(minutes=3) - result = np.timedelta64(5, 'm') % td - assert isinstance(result, Timedelta) - assert result == Timedelta(minutes=2) - - def test_td_rmod_invalid(self): - # GH#19365 - td = Timedelta(minutes=3) - - with pytest.raises(TypeError): - pd.Timestamp('2018-01-22') % td - - with pytest.raises(TypeError): - 15 % td - - with pytest.raises(TypeError): - 16.0 % td - - with pytest.raises(TypeError): - np.array([22, 24]) % td - - def test_td_divmod_numeric(self): - # GH#19365 - td = Timedelta(days=2, hours=6) - - result = divmod(td, 53 * 3600 * 1e9) - assert result[0] == Timedelta(1, unit='ns') - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(hours=1) - - assert result - result = divmod(td, np.nan) - assert result[0] is pd.NaT - assert result[1] is pd.NaT - - def test_td_divmod(self): - # GH#19365 - td = Timedelta(days=2, hours=6) - - result = divmod(td, timedelta(days=1)) - assert result[0] == 2 - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(hours=6) - - result = divmod(td, 54) - assert result[0] == Timedelta(hours=1) - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(0) - - result = divmod(td, pd.NaT) - assert np.isnan(result[0]) - assert result[1] is pd.NaT - - @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') - def test_td_divmod_offset(self): - # GH#19365 - td = Timedelta(days=2, hours=6) - - result = divmod(td, pd.offsets.Hour(-4)) - assert result[0] == -14 - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(hours=-2) - - def test_td_divmod_invalid(self): - # GH#19365 - td = Timedelta(days=2, hours=6) - - with pytest.raises(TypeError): - divmod(td, pd.Timestamp('2018-01-22')) - - def test_td_rdivmod_pytimedelta(self): - # GH#19365 - result = divmod(timedelta(days=2, hours=6), Timedelta(days=1)) - assert result[0] == 2 - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(hours=6) - - @pytest.mark.xfail(reason='GH#19378 floordiv by Tick not implemented') - def test_td_rdivmod_offset(self): - result = divmod(pd.offsets.Hour(54), Timedelta(hours=-4)) - assert result[0] == -14 - assert isinstance(result[1], Timedelta) - assert result[1] == Timedelta(hours=-2) - - def test_td_rdivmod_invalid(self): - # GH#19365 - td = Timedelta(minutes=3) - - with pytest.raises(TypeError): - divmod(pd.Timestamp('2018-01-22'), td) - - with pytest.raises(TypeError): - divmod(15, td) - - with pytest.raises(TypeError): - divmod(16.0, td) - - with pytest.raises(TypeError): - divmod(np.array([22, 24]), td) - class TestTimedeltaComparison(object): def test_comparison_object_array(self): From c78ed1b9136bac9551ef9aee5ff2e662da878cad Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 19 Feb 2018 09:47:12 -0800 Subject: [PATCH 4/5] remove duplicated doc line --- doc/source/whatsnew/v0.23.0.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 5c294022647a4..cf8a43a728f3c 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -585,7 +585,6 @@ Other API Changes - Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`) - :class:`DateOffset` objects render more simply, e.g. "" instead of "" (:issue:`19403`) - :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`) -- :func:`Timedelta.__mod__`, :func:`Timedelta.__divmod__` now accept timedelta-like and numeric arguments instead of raising ``TypeError`` (:issue:`19365`) .. _whatsnew_0230.deprecations: From aefa6d6e06524c6cf5f6f2fb0ad618b81244d0ef Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Mon, 19 Feb 2018 18:12:59 -0500 Subject: [PATCH 5/5] remove issue reference & fix ref --- doc/source/timedeltas.rst | 2 +- doc/source/whatsnew/v0.23.0.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 93b144d31c788..5f3a01f0725d4 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -285,7 +285,7 @@ Rounded division (floor-division) of a ``timedelta64[ns]`` Series by a scalar .. _timedeltas.mod_divmod: -The mod (%) and divmod operations are defined for ``Timedelta`` when operating with another timedelta-like or with a numeric argument. (:issue:`19365`) +The mod (%) and divmod operations are defined for ``Timedelta`` when operating with another timedelta-like or with a numeric argument. .. ipython:: python diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index cf8a43a728f3c..aa1e434aae6e9 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -124,7 +124,7 @@ Timedelta mod method ``mod`` (%) and ``divmod`` operations are now defined on ``Timedelta`` objects when operating with either timedelta-like or with numeric arguments. -See the :ref:`<_timedeltas.mod_divmod>` documentation section. (:issue:`19365`) +See the :ref:`documentation here `. (:issue:`19365`) .. ipython:: python