Skip to content

Commit 59cfd8c

Browse files
reidy-pTomAugspurger
authored andcommitted
BUG: Incorrect addition of Week(weekday=6) to DatetimeIndex (#22695)
* BUG: Incorrect addition of Week(weekday=6) to DatetimeIndex
1 parent 08bd3e3 commit 59cfd8c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pandas/tests/arithmetic/test_datetime64.py

+1
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ def test_dt64_with_DateOffsets_relativedelta(klass):
17641764
'MonthBegin', 'MonthEnd',
17651765
'SemiMonthEnd', 'SemiMonthBegin',
17661766
'Week', ('Week', {'weekday': 3}),
1767+
'Week', ('Week', {'weekday': 6}),
17671768
'BusinessDay', 'BDay', 'QuarterEnd', 'QuarterBegin',
17681769
'CustomBusinessDay', 'CDay', 'CBMonthEnd',
17691770
'CBMonthBegin', 'BMonthBegin', 'BMonthEnd',

pandas/tseries/offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ def _end_apply_index(self, dtindex):
13131313
base_period = dtindex.to_period(base)
13141314
if self.n > 0:
13151315
# when adding, dates on end roll to next
1316-
normed = dtindex - off
1316+
normed = dtindex - off + Timedelta(1, 'D') - Timedelta(1, 'ns')
13171317
roll = np.where(base_period.to_timestamp(how='end') == normed,
13181318
self.n, self.n - 1)
13191319
else:

0 commit comments

Comments
 (0)