From bca0d9190cc776c4a0d3712910947e44f26331dd Mon Sep 17 00:00:00 2001 From: Paul Reidy Date: Wed, 12 Sep 2018 23:16:13 +0100 Subject: [PATCH 1/3] BUG: Incorrect addition of Week(weekday=6) to DatetimeIndex --- doc/source/whatsnew/v0.24.0.txt | 2 +- pandas/tests/arithmetic/test_datetime64.py | 1 + pandas/tseries/offsets.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 232f879285543..a4d2e72345383 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -629,7 +629,7 @@ Datetimelike - Bug in :meth:`DataFrame.eq` comparison against ``NaT`` incorrectly returning ``True`` or ``NaN`` (:issue:`15697`, :issue:`22163`) - Bug in :class:`DatetimeIndex` subtraction that incorrectly failed to raise ``OverflowError`` (:issue:`22492`, :issue:`22508`) - Bug in :class:`DatetimeIndex` incorrectly allowing indexing with ``Timedelta`` object (:issue:`20464`) -- +- Bug in :class:`DatetimeIndex` where addition of Week offset with weekday=6 had no effect (:issue:`22465`) Timedelta ^^^^^^^^^ diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index a3fa4e6b88256..b19cc61a2999e 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -1764,6 +1764,7 @@ def test_dt64_with_DateOffsets_relativedelta(klass): 'MonthBegin', 'MonthEnd', 'SemiMonthEnd', 'SemiMonthBegin', 'Week', ('Week', {'weekday': 3}), + 'Week', ('Week', {'weekday': 6}), 'BusinessDay', 'BDay', 'QuarterEnd', 'QuarterBegin', 'CustomBusinessDay', 'CDay', 'CBMonthEnd', 'CBMonthBegin', 'BMonthBegin', 'BMonthEnd', diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index d4a8211c17b87..0a9931c46bbd5 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -1313,7 +1313,7 @@ def _end_apply_index(self, dtindex): base_period = dtindex.to_period(base) if self.n > 0: # when adding, dates on end roll to next - normed = dtindex - off + normed = dtindex - off + Timedelta(1, 'D') - Timedelta(1, 'ns') roll = np.where(base_period.to_timestamp(how='end') == normed, self.n, self.n - 1) else: From 4c91f81c6d05048bfa199fc55519445b06cfc668 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 14 Sep 2018 06:13:05 -0500 Subject: [PATCH 2/3] Update v0.24.0.txt --- doc/source/whatsnew/v0.24.0.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index a4d2e72345383..9170b433dc48a 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -629,7 +629,6 @@ Datetimelike - Bug in :meth:`DataFrame.eq` comparison against ``NaT`` incorrectly returning ``True`` or ``NaN`` (:issue:`15697`, :issue:`22163`) - Bug in :class:`DatetimeIndex` subtraction that incorrectly failed to raise ``OverflowError`` (:issue:`22492`, :issue:`22508`) - Bug in :class:`DatetimeIndex` incorrectly allowing indexing with ``Timedelta`` object (:issue:`20464`) -- Bug in :class:`DatetimeIndex` where addition of Week offset with weekday=6 had no effect (:issue:`22465`) Timedelta ^^^^^^^^^ From 6cbdaabeee01b5237d13e4c1be2815165ee8a2ab Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 14 Sep 2018 06:13:38 -0500 Subject: [PATCH 3/3] Update v0.24.0.txt --- doc/source/whatsnew/v0.24.0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 9170b433dc48a..232f879285543 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -629,6 +629,7 @@ Datetimelike - Bug in :meth:`DataFrame.eq` comparison against ``NaT`` incorrectly returning ``True`` or ``NaN`` (:issue:`15697`, :issue:`22163`) - Bug in :class:`DatetimeIndex` subtraction that incorrectly failed to raise ``OverflowError`` (:issue:`22492`, :issue:`22508`) - Bug in :class:`DatetimeIndex` incorrectly allowing indexing with ``Timedelta`` object (:issue:`20464`) +- Timedelta ^^^^^^^^^