@@ -994,6 +994,47 @@ def test_merge_on_datetime64tz(self):
994
994
result = pd .merge (left , right , on = 'key' , how = 'outer' )
995
995
assert_frame_equal (result , expected )
996
996
997
+ def test_concat_Nat_series (self ):
998
+ # GH 11693
999
+ # test for merging NaT series with datetime series.
1000
+ x = pd .Series ( pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "US/Eastern" ))
1001
+ y = pd .Series ( pd .date_range ('20151124 10:00' , '20151124 11:00' , freq = '1h' , tz = "US/Eastern" ))
1002
+ y [:] = pd .NaT
1003
+ expected = pd .Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ], index = [0 , 1 , 0 , 1 ])
1004
+ tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1005
+
1006
+ # all NaT with tz
1007
+ x [:] = pd .NaT
1008
+ expected = pd .Series ([pd .NaT for i in range (4 )], index = [0 , 1 , 0 , 1 ], dtype = 'datetime64[ns, US/Eastern]' )
1009
+ tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1010
+
1011
+ #without tz
1012
+ x = pd .Series ( pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' ))
1013
+ y = pd .Series ( pd .date_range ('20151124 10:00' , '20151124 11:00' , freq = '1h' ))
1014
+ y [:] = pd .NaT
1015
+ expected = pd .Series ([x [0 ], x [1 ], pd .NaT , pd .NaT ], index = [0 , 1 , 0 , 1 ])
1016
+ tm .assert_series_equal (pd .concat ([x , y ]), expected )
1017
+
1018
+ #all NaT without tz
1019
+ x [:] = pd .NaT
1020
+ expected = pd .Series ([pd .NaT for i in range (4 )], index = [0 , 1 , 0 , 1 ], dtype = 'datetime64[ns]' )
1021
+ tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1022
+
1023
+ def test_concat_tz_series (self ):
1024
+ #tz and no tz
1025
+ #GH 11755
1026
+ x = pd .Series (pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "UTC" ) )
1027
+ y = pd .Series (pd .date_range ('2012-01-01' , '2012-01-02' ))
1028
+ expected = pd .Series ([x [0 ], x [1 ], y [0 ], y [1 ]], index = [0 , 1 , 0 , 1 ], dtype = 'object' )
1029
+ tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1030
+
1031
+ #tz and object
1032
+ #GH 11887
1033
+ x = pd .Series (pd .date_range ('20151124 08:00' , '20151124 09:00' , freq = '1h' , tz = "UTC" ) )
1034
+ y = pd .Series (['a' , 'b' ])
1035
+ expected = pd .Series ([x [0 ], x [1 ], y [0 ], y [1 ]], index = [0 , 1 , 0 , 1 ], dtype = 'object' )
1036
+ tm .assert_series_equal (pd .concat ([x ,y ]), expected )
1037
+
997
1038
def test_indicator (self ):
998
1039
# PR #10054. xref #7412 and closes #8790.
999
1040
df1 = DataFrame ({'col1' :[0 ,1 ], 'col_left' :['a' ,'b' ], 'col_conflict' :[1 ,2 ]})
0 commit comments