@@ -412,6 +412,14 @@ def test_dti_shift_no_freq(self):
412
412
with pytest .raises (NullFrequencyError ):
413
413
dti .shift (2 )
414
414
415
+ @pytest .mark .parametrize ('tzstr' , ['US/Eastern' , 'dateutil/US/Eastern' ])
416
+ def test_dti_shift_localized (self , tzstr ):
417
+ dr = date_range ('2011/1/1' , '2012/1/1' , freq = 'W-FRI' )
418
+ dr_tz = dr .tz_localize (tzstr )
419
+
420
+ result = dr_tz .shift (1 , '10T' )
421
+ assert result .tz == dr_tz .tz
422
+
415
423
# -------------------------------------------------------------
416
424
# Binary operations DatetimeIndex and timedelta-like
417
425
@@ -767,6 +775,24 @@ def test_dti_with_offset_series(self, tz, names):
767
775
res3 = dti - other
768
776
tm .assert_series_equal (res3 , expected_sub )
769
777
778
+ def test_dti_add_offset_tzaware (self ):
779
+ dates = date_range ('2012-11-01' , periods = 3 , tz = 'US/Pacific' )
780
+ offset = dates + pd .offsets .Hour (5 )
781
+ assert dates [0 ] + pd .offsets .Hour (5 ) == offset [0 ]
782
+
783
+ # GH#6818
784
+ for tz in ['UTC' , 'US/Pacific' , 'Asia/Tokyo' ]:
785
+ dates = date_range ('2010-11-01 00:00' , periods = 3 , tz = tz , freq = 'H' )
786
+ expected = DatetimeIndex (['2010-11-01 05:00' , '2010-11-01 06:00' ,
787
+ '2010-11-01 07:00' ], freq = 'H' , tz = tz )
788
+
789
+ offset = dates + pd .offsets .Hour (5 )
790
+ tm .assert_index_equal (offset , expected )
791
+ offset = dates + np .timedelta64 (5 , 'h' )
792
+ tm .assert_index_equal (offset , expected )
793
+ offset = dates + timedelta (hours = 5 )
794
+ tm .assert_index_equal (offset , expected )
795
+
770
796
771
797
@pytest .mark .parametrize ('klass,assert_func' , [
772
798
(Series , tm .assert_series_equal ),
0 commit comments