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