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