@@ -1024,6 +1024,63 @@ 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 ):
1028
+ # GH 11693
1029
+ # test for merging NaT series with datetime series.
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 )
1037
+
1038
+ # all NaT with tz
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 )
1043
+
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' ))
1049
+ y [:] = pd .NaT
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 )
1053
+
1054
+ # all NaT without tz
1055
+ x [:] = pd .NaT
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 )
1060
+
1061
+ def test_concat_tz_series (self ):
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 )
1083
+
1027
1084
def test_indicator (self ):
1028
1085
# PR #10054. xref #7412 and closes #8790.
1029
1086
df1 = DataFrame ({'col1' : [0 , 1 ], 'col_left' : [
0 commit comments