@@ -1370,14 +1370,6 @@ def test_dt64arr_add_sub_DateOffset(self, box_with_array):
1370
1370
tm .assert_equal (result , exp )
1371
1371
tm .assert_equal (result2 , exp )
1372
1372
1373
- # GH 26258
1374
- date = date_range (start = '01 Jan 2014' , end = '01 Jan 2017' , freq = 'AS' )
1375
- offset = pd .DateOffset (months = 3 , days = 10 )
1376
- result = date + offset
1377
- exp = DatetimeIndex ([Timestamp ('2014-04-11' ), Timestamp ('2015-04-11' ),
1378
- Timestamp ('2016-04-11' ), Timestamp ('2017-04-11' )])
1379
- tm .assert_equal (result , exp )
1380
-
1381
1373
# TODO: __sub__, __rsub__
1382
1374
def test_dt64arr_add_mixed_offset_array (self , box_with_array ):
1383
1375
# GH#10699
@@ -1443,6 +1435,28 @@ def test_dt64arr_add_sub_offset_ndarray(self, tz_naive_fixture,
1443
1435
expected = tm .box_expected (expected , box_with_array )
1444
1436
tm .assert_equal (res , expected )
1445
1437
1438
+ @pytest .mark .parametrize ("op, offset, exp" , [
1439
+ ('__add__' , pd .DateOffset (months = 3 , days = 10 ),
1440
+ DatetimeIndex ([Timestamp ('2014-04-11' ), Timestamp ('2015-04-11' ),
1441
+ Timestamp ('2016-04-11' ), Timestamp ('2017-04-11' )])),
1442
+ ('__add__' , pd .DateOffset (months = 3 ),
1443
+ DatetimeIndex ([Timestamp ('2014-04-01' ), Timestamp ('2015-04-01' ),
1444
+ Timestamp ('2016-04-01' ), Timestamp ('2017-04-01' )])),
1445
+ ('__sub__' , pd .DateOffset (months = 3 , days = 10 ),
1446
+ DatetimeIndex ([Timestamp ('2013-09-21' ), Timestamp ('2014-09-21' ),
1447
+ Timestamp ('2015-09-21' ), Timestamp ('2016-09-21' )])),
1448
+ ('__sub__' , pd .DateOffset (months = 3 ),
1449
+ DatetimeIndex ([Timestamp ('2013-10-01' ), Timestamp ('2014-10-01' ),
1450
+ Timestamp ('2015-10-01' ), Timestamp ('2016-10-01' )]))
1451
+
1452
+ ])
1453
+ def test_dti_add_sub_nonzero_mth_offset (self , op , offset , exp ):
1454
+ # GH 26258
1455
+ date = date_range (start = '01 Jan 2014' , end = '01 Jan 2017' , freq = 'AS' )
1456
+ mth = getattr (date , op )
1457
+ result = mth (offset )
1458
+ tm .assert_equal (result , exp )
1459
+
1446
1460
1447
1461
class TestDatetime64OverflowHandling :
1448
1462
# TODO: box + de-duplicate
0 commit comments