@@ -3826,6 +3826,37 @@ def test_factorize(self):
3826
3826
self .assert_numpy_array_equal (arr , exp_arr )
3827
3827
tm .assert_index_equal (idx , idx3 )
3828
3828
3829
+ def test_factorize_tz (self ):
3830
+ # GH 13750
3831
+ for tz in [None , 'UTC' , 'US/Eastern' , 'Asia/Tokyo' ]:
3832
+ base = pd .date_range ('2016-11-05' , freq = 'H' , periods = 100 , tz = tz )
3833
+ idx = base .repeat (5 )
3834
+
3835
+ exp_arr = np .arange (100 ).repeat (5 )
3836
+
3837
+ for obj in [idx , pd .Series (idx )]:
3838
+ arr , res = obj .factorize ()
3839
+ self .assert_numpy_array_equal (arr , exp_arr )
3840
+ tm .assert_index_equal (res , base )
3841
+
3842
+ def test_factorize_dst (self ):
3843
+ # GH 13750
3844
+ idx = pd .date_range ('2016-11-06' , freq = 'H' , periods = 12 ,
3845
+ tz = 'US/Eastern' )
3846
+
3847
+ for obj in [idx , pd .Series (idx )]:
3848
+ arr , res = obj .factorize ()
3849
+ self .assert_numpy_array_equal (arr , np .arange (12 ))
3850
+ tm .assert_index_equal (res , idx )
3851
+
3852
+ idx = pd .date_range ('2016-06-13' , freq = 'H' , periods = 12 ,
3853
+ tz = 'US/Eastern' )
3854
+
3855
+ for obj in [idx , pd .Series (idx )]:
3856
+ arr , res = obj .factorize ()
3857
+ self .assert_numpy_array_equal (arr , np .arange (12 ))
3858
+ tm .assert_index_equal (res , idx )
3859
+
3829
3860
def test_slice_with_negative_step (self ):
3830
3861
ts = Series (np .arange (20 ),
3831
3862
date_range ('2014-01-01' , periods = 20 , freq = 'MS' ))
0 commit comments