@@ -461,23 +461,26 @@ def test_merge_na_keys(self):
461
461
tm .assert_frame_equal (result , expected )
462
462
463
463
def test_merge_datetime_index_empty_df (self ):
464
- data = [
465
- [pd .Timestamp ("1950-01-01" ), "A" , 1.5 ],
466
- [pd .Timestamp ("1950-01-02" ), "B" , 1.5 ],
467
- ]
468
464
469
- frame = DataFrame (data , columns = ["date" , "panel" , "data" ]).set_index (
465
+ date = np .array (
466
+ [pd .Timestamp ("1950-01-01" ), pd .Timestamp ("1950-01-02" )],
467
+ dtype = np .datetime64 ,
468
+ )
469
+ panel = np .array (["A" , "B" ], dtype = object )
470
+ data = np .array ([1.5 , 1.5 ], dtype = np .float64 )
471
+
472
+ frame = DataFrame ({"date" : date , "panel" : panel , "data" : data }).set_index (
470
473
["date" , "panel" ]
471
474
)
472
475
other = DataFrame (columns = ["date" , "panel" , "state" ]).set_index (
473
476
["date" , "panel" ]
474
477
)
475
- expected_data = [
476
- [pd .Timestamp ("1950-01-01" ), "A" , 1.5 , pd .NA ],
477
- [pd .Timestamp ("1950-01-02" ), "B" , 1.5 , pd .NA ],
478
- ]
479
478
480
- expected = DataFrame (expected_data , columns = ["date" , "panel" , "data" , "state" ])
479
+ state = np .array ([np .nan , np .nan ], dtype = object )
480
+
481
+ expected = DataFrame (
482
+ {"date" : date , "panel" : panel , "data" : data , "state" : state }
483
+ )
481
484
expected = expected .set_index (["date" , "panel" ])
482
485
483
486
result = frame .merge (other , how = "left" , on = ["date" , "panel" ])
0 commit comments