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