@@ -358,8 +358,8 @@ def test_field_access_localize(self):
358
358
dr = date_range ('2011-10-02 00:00' , freq = 'h' , periods = 10 ,
359
359
tz = self .tzstr ('America/Atikokan' ))
360
360
361
- expected = np .arange (10 , dtype = np .int32 )
362
- self .assert_numpy_array_equal (dr .hour , expected )
361
+ expected = pd . Index ( np .arange (10 , dtype = np .int64 ) )
362
+ self .assert_index_equal (dr .hour , expected )
363
363
364
364
def test_with_tz (self ):
365
365
tz = self .tz ('US/Central' )
@@ -947,35 +947,35 @@ def test_tz_convert_hour_overflow_dst(self):
947
947
'2009-05-12 09:50:32' ]
948
948
tt = to_datetime (ts ).tz_localize ('US/Eastern' )
949
949
ut = tt .tz_convert ('UTC' )
950
- expected = np . array ([13 , 14 , 13 ], dtype = np . int32 )
951
- self .assert_numpy_array_equal (ut .hour , expected )
950
+ expected = Index ([13 , 14 , 13 ])
951
+ self .assert_index_equal (ut .hour , expected )
952
952
953
953
# sorted case UTC -> US/Eastern
954
954
ts = ['2008-05-12 13:50:00' ,
955
955
'2008-12-12 14:50:35' ,
956
956
'2009-05-12 13:50:32' ]
957
957
tt = to_datetime (ts ).tz_localize ('UTC' )
958
958
ut = tt .tz_convert ('US/Eastern' )
959
- expected = np . array ([9 , 9 , 9 ], dtype = np . int32 )
960
- self .assert_numpy_array_equal (ut .hour , expected )
959
+ expected = Index ([9 , 9 , 9 ])
960
+ self .assert_index_equal (ut .hour , expected )
961
961
962
962
# unsorted case US/Eastern -> UTC
963
963
ts = ['2008-05-12 09:50:00' ,
964
964
'2008-12-12 09:50:35' ,
965
965
'2008-05-12 09:50:32' ]
966
966
tt = to_datetime (ts ).tz_localize ('US/Eastern' )
967
967
ut = tt .tz_convert ('UTC' )
968
- expected = np . array ([13 , 14 , 13 ], dtype = np . int32 )
969
- self .assert_numpy_array_equal (ut .hour , expected )
968
+ expected = Index ([13 , 14 , 13 ])
969
+ self .assert_index_equal (ut .hour , expected )
970
970
971
971
# unsorted case UTC -> US/Eastern
972
972
ts = ['2008-05-12 13:50:00' ,
973
973
'2008-12-12 14:50:35' ,
974
974
'2008-05-12 13:50:32' ]
975
975
tt = to_datetime (ts ).tz_localize ('UTC' )
976
976
ut = tt .tz_convert ('US/Eastern' )
977
- expected = np . array ([9 , 9 , 9 ], dtype = np . int32 )
978
- self .assert_numpy_array_equal (ut .hour , expected )
977
+ expected = Index ([9 , 9 , 9 ])
978
+ self .assert_index_equal (ut .hour , expected )
979
979
980
980
def test_tz_convert_hour_overflow_dst_timestamps (self ):
981
981
# Regression test for:
@@ -989,35 +989,35 @@ def test_tz_convert_hour_overflow_dst_timestamps(self):
989
989
Timestamp ('2009-05-12 09:50:32' , tz = tz )]
990
990
tt = to_datetime (ts )
991
991
ut = tt .tz_convert ('UTC' )
992
- expected = np . array ([13 , 14 , 13 ], dtype = np . int32 )
993
- self .assert_numpy_array_equal (ut .hour , expected )
992
+ expected = Index ([13 , 14 , 13 ])
993
+ self .assert_index_equal (ut .hour , expected )
994
994
995
995
# sorted case UTC -> US/Eastern
996
996
ts = [Timestamp ('2008-05-12 13:50:00' , tz = 'UTC' ),
997
997
Timestamp ('2008-12-12 14:50:35' , tz = 'UTC' ),
998
998
Timestamp ('2009-05-12 13:50:32' , tz = 'UTC' )]
999
999
tt = to_datetime (ts )
1000
1000
ut = tt .tz_convert ('US/Eastern' )
1001
- expected = np . array ([9 , 9 , 9 ], dtype = np . int32 )
1002
- self .assert_numpy_array_equal (ut .hour , expected )
1001
+ expected = Index ([9 , 9 , 9 ])
1002
+ self .assert_index_equal (ut .hour , expected )
1003
1003
1004
1004
# unsorted case US/Eastern -> UTC
1005
1005
ts = [Timestamp ('2008-05-12 09:50:00' , tz = tz ),
1006
1006
Timestamp ('2008-12-12 09:50:35' , tz = tz ),
1007
1007
Timestamp ('2008-05-12 09:50:32' , tz = tz )]
1008
1008
tt = to_datetime (ts )
1009
1009
ut = tt .tz_convert ('UTC' )
1010
- expected = np . array ([13 , 14 , 13 ], dtype = np . int32 )
1011
- self .assert_numpy_array_equal (ut .hour , expected )
1010
+ expected = Index ([13 , 14 , 13 ])
1011
+ self .assert_index_equal (ut .hour , expected )
1012
1012
1013
1013
# unsorted case UTC -> US/Eastern
1014
1014
ts = [Timestamp ('2008-05-12 13:50:00' , tz = 'UTC' ),
1015
1015
Timestamp ('2008-12-12 14:50:35' , tz = 'UTC' ),
1016
1016
Timestamp ('2008-05-12 13:50:32' , tz = 'UTC' )]
1017
1017
tt = to_datetime (ts )
1018
1018
ut = tt .tz_convert ('US/Eastern' )
1019
- expected = np . array ([9 , 9 , 9 ], dtype = np . int32 )
1020
- self .assert_numpy_array_equal (ut .hour , expected )
1019
+ expected = Index ([9 , 9 , 9 ])
1020
+ self .assert_index_equal (ut .hour , expected )
1021
1021
1022
1022
def test_tslib_tz_convert_trans_pos_plus_1__bug (self ):
1023
1023
# Regression test for tslib.tz_convert(vals, tz1, tz2).
@@ -1028,9 +1028,8 @@ def test_tslib_tz_convert_trans_pos_plus_1__bug(self):
1028
1028
idx = idx .tz_localize ('UTC' )
1029
1029
idx = idx .tz_convert ('Europe/Moscow' )
1030
1030
1031
- expected = np .repeat (np .array ([3 , 4 , 5 ], dtype = np .int32 ),
1032
- np .array ([n , n , 1 ]))
1033
- self .assert_numpy_array_equal (idx .hour , expected )
1031
+ expected = np .repeat (np .array ([3 , 4 , 5 ]), np .array ([n , n , 1 ]))
1032
+ self .assert_index_equal (idx .hour , Index (expected ))
1034
1033
1035
1034
def test_tslib_tz_convert_dst (self ):
1036
1035
for freq , n in [('H' , 1 ), ('T' , 60 ), ('S' , 3600 )]:
@@ -1039,62 +1038,57 @@ def test_tslib_tz_convert_dst(self):
1039
1038
tz = 'UTC' )
1040
1039
idx = idx .tz_convert ('US/Eastern' )
1041
1040
expected = np .repeat (np .array ([18 , 19 , 20 , 21 , 22 , 23 ,
1042
- 0 , 1 , 3 , 4 , 5 ], dtype = np . int32 ),
1041
+ 0 , 1 , 3 , 4 , 5 ]),
1043
1042
np .array ([n , n , n , n , n , n , n , n , n , n , 1 ]))
1044
- self .assert_numpy_array_equal (idx .hour , expected )
1043
+ self .assert_index_equal (idx .hour , Index ( expected ) )
1045
1044
1046
1045
idx = date_range ('2014-03-08 18:00' , '2014-03-09 05:00' , freq = freq ,
1047
1046
tz = 'US/Eastern' )
1048
1047
idx = idx .tz_convert ('UTC' )
1049
- expected = np .repeat (np .array ([23 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ],
1050
- dtype = np .int32 ),
1048
+ expected = np .repeat (np .array ([23 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]),
1051
1049
np .array ([n , n , n , n , n , n , n , n , n , n , 1 ]))
1052
- self .assert_numpy_array_equal (idx .hour , expected )
1050
+ self .assert_index_equal (idx .hour , Index ( expected ) )
1053
1051
1054
1052
# End DST
1055
1053
idx = date_range ('2014-11-01 23:00' , '2014-11-02 09:00' , freq = freq ,
1056
1054
tz = 'UTC' )
1057
1055
idx = idx .tz_convert ('US/Eastern' )
1058
1056
expected = np .repeat (np .array ([19 , 20 , 21 , 22 , 23 ,
1059
- 0 , 1 , 1 , 2 , 3 , 4 ], dtype = np . int32 ),
1057
+ 0 , 1 , 1 , 2 , 3 , 4 ]),
1060
1058
np .array ([n , n , n , n , n , n , n , n , n , n , 1 ]))
1061
- self .assert_numpy_array_equal (idx .hour , expected )
1059
+ self .assert_index_equal (idx .hour , Index ( expected ) )
1062
1060
1063
1061
idx = date_range ('2014-11-01 18:00' , '2014-11-02 05:00' , freq = freq ,
1064
1062
tz = 'US/Eastern' )
1065
1063
idx = idx .tz_convert ('UTC' )
1066
1064
expected = np .repeat (np .array ([22 , 23 , 0 , 1 , 2 , 3 , 4 , 5 , 6 ,
1067
- 7 , 8 , 9 , 10 ], dtype = np . int32 ),
1065
+ 7 , 8 , 9 , 10 ]),
1068
1066
np .array ([n , n , n , n , n , n , n , n , n ,
1069
1067
n , n , n , 1 ]))
1070
- self .assert_numpy_array_equal (idx .hour , expected )
1068
+ self .assert_index_equal (idx .hour , Index ( expected ) )
1071
1069
1072
1070
# daily
1073
1071
# Start DST
1074
1072
idx = date_range ('2014-03-08 00:00' , '2014-03-09 00:00' , freq = 'D' ,
1075
1073
tz = 'UTC' )
1076
1074
idx = idx .tz_convert ('US/Eastern' )
1077
- self .assert_numpy_array_equal (idx .hour ,
1078
- np .array ([19 , 19 ], dtype = np .int32 ))
1075
+ self .assert_index_equal (idx .hour , Index ([19 , 19 ]))
1079
1076
1080
1077
idx = date_range ('2014-03-08 00:00' , '2014-03-09 00:00' , freq = 'D' ,
1081
1078
tz = 'US/Eastern' )
1082
1079
idx = idx .tz_convert ('UTC' )
1083
- self .assert_numpy_array_equal (idx .hour ,
1084
- np .array ([5 , 5 ], dtype = np .int32 ))
1080
+ self .assert_index_equal (idx .hour , Index ([5 , 5 ]))
1085
1081
1086
1082
# End DST
1087
1083
idx = date_range ('2014-11-01 00:00' , '2014-11-02 00:00' , freq = 'D' ,
1088
1084
tz = 'UTC' )
1089
1085
idx = idx .tz_convert ('US/Eastern' )
1090
- self .assert_numpy_array_equal (idx .hour ,
1091
- np .array ([20 , 20 ], dtype = np .int32 ))
1086
+ self .assert_index_equal (idx .hour , Index ([20 , 20 ]))
1092
1087
1093
1088
idx = date_range ('2014-11-01 00:00' , '2014-11-02 000:00' , freq = 'D' ,
1094
1089
tz = 'US/Eastern' )
1095
1090
idx = idx .tz_convert ('UTC' )
1096
- self .assert_numpy_array_equal (idx .hour ,
1097
- np .array ([4 , 4 ], dtype = np .int32 ))
1091
+ self .assert_index_equal (idx .hour , Index ([4 , 4 ]))
1098
1092
1099
1093
def test_tzlocal (self ):
1100
1094
# GH 13583
0 commit comments