@@ -1024,46 +1024,62 @@ def test_merge_on_datetime64tz(self):
1024
1024
result = pd .merge (left , right , on = 'key' , how = 'outer' )
1025
1025
assert_frame_equal (result , expected )
1026
1026
1027
- def test_concat_Nat_series (self ):
1027
+ def test_concat_NaT_series (self ):
1028
1028
# GH 11693
1029
1029
# test for merging NaT series with datetime series.
1030
- x = pd .Series ( pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "US/Eastern" ))
1031
- y = pd .Series ( pd .date_range ('20151124 10:00' , '20151124 11:00' , freq = '1h' , tz = "US/Eastern" ))
1032
- y [:] = pd .NaT
1033
- expected = pd .Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ], index = [0 , 1 , 0 , 1 ])
1034
- tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1030
+ x = Series (date_range ('20151124 08:00' , '20151124 09:00' ,
1031
+ freq = '1h' , tz = 'US/Eastern' ))
1032
+ y = Series (pd .NaT , index = [0 , 1 ], dtype = 'datetime64[ns, US/Eastern]' )
1033
+ expected = Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ])
1034
+
1035
+ result = concat ([x , y ], ignore_index = True )
1036
+ tm .assert_series_equal (result , expected )
1035
1037
1036
1038
# all NaT with tz
1037
- x [:] = pd .NaT
1038
- expected = pd .Series ([pd .NaT for i in range (4 )], index = [0 , 1 , 0 , 1 ], dtype = 'datetime64[ns, US/Eastern]' )
1039
- tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1039
+ expected = Series (pd .NaT , index = range (4 ),
1040
+ dtype = 'datetime64[ns, US/Eastern]' )
1041
+ result = pd .concat ([y , y ], ignore_index = True )
1042
+ tm .assert_series_equal (result , expected )
1040
1043
1041
- #without tz
1042
- x = pd .Series ( pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' ))
1043
- y = pd .Series ( pd .date_range ('20151124 10:00' , '20151124 11:00' , freq = '1h' ))
1044
+ # without tz
1045
+ x = pd .Series (pd .date_range ('20151124 08:00' ,
1046
+ '20151124 09:00' , freq = '1h' ))
1047
+ y = pd .Series (pd .date_range ('20151124 10:00' ,
1048
+ '20151124 11:00' , freq = '1h' ))
1044
1049
y [:] = pd .NaT
1045
- expected = pd .Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ], index = [0 , 1 , 0 , 1 ])
1046
- tm .assert_series_equal (pd .concat ([x , y ]), expected )
1050
+ expected = pd .Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ])
1051
+ result = pd .concat ([x , y ], ignore_index = True )
1052
+ tm .assert_series_equal (result , expected )
1047
1053
1048
- #all NaT without tz
1054
+ # all NaT without tz
1049
1055
x [:] = pd .NaT
1050
- expected = pd .Series ([pd .NaT for i in range (4 )], index = [0 , 1 , 0 , 1 ], dtype = 'datetime64[ns]' )
1051
- tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1056
+ expected = pd .Series (pd .NaT , index = range (4 ),
1057
+ dtype = 'datetime64[ns]' )
1058
+ result = pd .concat ([x , y ], ignore_index = True )
1059
+ tm .assert_series_equal (result , expected )
1052
1060
1053
1061
def test_concat_tz_series (self ):
1054
- #tz and no tz
1055
- #GH 11755
1056
- x = pd .Series (pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "UTC" ) )
1057
- y = pd .Series (pd .date_range ('2012-01-01' , '2012-01-02' ))
1058
- expected = pd .Series ([x [0 ], x [1 ], y [0 ], y [1 ]], index = [0 , 1 , 0 , 1 ], dtype = 'object' )
1059
- tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1060
-
1061
- #tz and object
1062
- #GH 11887
1063
- x = pd .Series (pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "UTC" ) )
1064
- y = pd .Series (['a' , 'b' ])
1065
- expected = pd .Series ([x [0 ], x [1 ], y [0 ], y [1 ]], index = [0 , 1 , 0 , 1 ], dtype = 'object' )
1066
- tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1062
+ # GH 11755
1063
+ # tz and no tz
1064
+ x = Series (date_range ('20151124 08:00' ,
1065
+ '20151124 09:00' ,
1066
+ freq = '1h' , tz = 'UTC' ))
1067
+ y = Series (date_range ('2012-01-01' , '2012-01-02' ))
1068
+ expected = Series ([x [0 ], x [1 ], y [0 ], y [1 ]],
1069
+ dtype = 'object' )
1070
+ result = concat ([x , y ], ignore_index = True )
1071
+ tm .assert_series_equal (result , expected )
1072
+
1073
+ # GH 11887
1074
+ # concat tz and object
1075
+ x = Series (date_range ('20151124 08:00' ,
1076
+ '20151124 09:00' ,
1077
+ freq = '1h' , tz = 'UTC' ))
1078
+ y = Series (['a' , 'b' ])
1079
+ expected = Series ([x [0 ], x [1 ], y [0 ], y [1 ]],
1080
+ dtype = 'object' )
1081
+ result = concat ([x , y ], ignore_index = True )
1082
+ tm .assert_series_equal (result , expected )
1067
1083
1068
1084
def test_indicator (self ):
1069
1085
# PR #10054. xref #7412 and closes #8790.
0 commit comments