@@ -1024,6 +1024,47 @@ 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 = 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 )
1035
+
1036
+ # 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 )
1040
+
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
+ 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 )
1047
+
1048
+ #all NaT without tz
1049
+ 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 )
1052
+
1053
+ 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 )
1067
+
1027
1068
def test_indicator (self ):
1028
1069
# PR #10054. xref #7412 and closes #8790.
1029
1070
df1 = DataFrame ({'col1' : [0 , 1 ], 'col_left' : [
0 commit comments