@@ -400,7 +400,7 @@ def test_add_iadd(self):
400
400
(rng2 , other2 , expected2 ),
401
401
(rng3 , other3 , expected3 )]:
402
402
# previously performed setop (deprecated in 0.16.0), now
403
- # raises TypeError (GH.. )
403
+ # raises TypeError (GH14164 )
404
404
with tm .assertRaises (TypeError ):
405
405
rng + other
406
406
@@ -440,7 +440,7 @@ def test_add_iadd(self):
440
440
441
441
def test_add_dti_dti (self ):
442
442
# previously performed setop (deprecated in 0.16.0), now raises
443
- # TypeError (GH.. )
443
+ # TypeError (GH14164 )
444
444
445
445
dti = date_range ('20130101' , periods = 3 )
446
446
dti_tz = date_range ('20130101' , periods = 3 ).tz_localize ('US/Eastern' )
@@ -480,27 +480,17 @@ def test_diff(self):
480
480
481
481
def test_sub_isub (self ):
482
482
for tz in self .tz :
483
- rng1 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
484
- other1 = pd .date_range ('1/6/2000' , freq = 'D' , periods = 5 , tz = tz )
485
- expected1 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
486
-
487
- rng2 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
488
- other2 = pd .date_range ('1/4/2000' , freq = 'D' , periods = 5 , tz = tz )
489
- expected2 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 3 , tz = tz )
490
-
491
- rng3 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
492
- other3 = pd .DatetimeIndex ([], tz = tz )
493
- expected3 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
494
483
495
484
# offset
496
485
offsets = [pd .offsets .Hour (2 ), timedelta (hours = 2 ),
497
486
np .timedelta64 (2 , 'h' ), Timedelta (hours = 2 )]
498
487
499
488
for delta in offsets :
500
489
rng = pd .date_range ('2000-01-01' , '2000-02-01' , tz = tz )
501
- result = rng - delta
502
490
expected = pd .date_range ('1999-12-31 22:00' ,
503
491
'2000-01-31 22:00' , tz = tz )
492
+
493
+ result = rng - delta
504
494
tm .assert_index_equal (result , expected )
505
495
rng -= delta
506
496
tm .assert_index_equal (rng , expected )
@@ -539,6 +529,18 @@ def test_sub_dti_dti(self):
539
529
with tm .assertRaises (TypeError ):
540
530
dti_tz - dti_tz2
541
531
532
+ # different length raises ValueError
533
+ dti2 = date_range ('20130101' , periods = 4 )
534
+ with tm .assertRaises (ValueError ):
535
+ dti - dti2
536
+
537
+ # NaN propagation
538
+ dti1 = DatetimeIndex (['2012-01-01' , np .nan , '2012-01-03' ])
539
+ dti2 = DatetimeIndex (['2012-01-02' , '2012-01-03' , np .nan ])
540
+ expected = TimedeltaIndex (['1 days' , np .nan , np .nan ])
541
+ result = dti2 - dti1
542
+ tm .assert_index_equal (result , expected )
543
+
542
544
def test_sub_period (self ):
543
545
# GH 13078
544
546
# not supported, check TypeError
0 commit comments