@@ -458,7 +458,7 @@ def test_merge_na_keys(self):
458
458
459
459
tm .assert_frame_equal (result , expected )
460
460
461
- def test_merge_na_datetime_keys_empty_df (self ):
461
+ def test_merge_datetime_index_empty_df (self ):
462
462
data = [
463
463
[pd .Timestamp ("1950-01-01" ), "A" , 1.5 ],
464
464
[pd .Timestamp ("1950-01-02" ), "B" , 1.5 ],
@@ -474,16 +474,22 @@ def test_merge_na_datetime_keys_empty_df(self):
474
474
frame = DataFrame (data , columns = ["date" , "panel" , "data" ]).set_index (
475
475
["date" , "panel" ]
476
476
)
477
-
478
- other_data = []
479
- other = DataFrame (other_data , columns = ["date" , "panel" , "state" ]).set_index (
477
+ other = DataFrame (columns = ["date" , "panel" , "state" ]).set_index (
480
478
["date" , "panel" ]
481
479
)
482
-
483
- expected = DataFrame ([], columns = ["date" , "panel" , "data" , "state" ])
484
- expected [["date" , "panel" , "data" ]] = frame .reset_index ()[
485
- ["date" , "panel" , "data" ]
480
+ expected_data = [
481
+ [pd .Timestamp ("1950-01-01" ), "A" , 1.5 , pd .NA ],
482
+ [pd .Timestamp ("1950-01-02" ), "B" , 1.5 , pd .NA ],
483
+ [pd .Timestamp ("1950-01-03" ), "B" , 1.5 , pd .NA ],
484
+ [pd .Timestamp ("1950-01-04" ), "B" , np .nan , pd .NA ],
485
+ [pd .Timestamp ("1950-01-05" ), "B" , 4.0 , pd .NA ],
486
+ [pd .Timestamp ("1950-01-06" ), "C" , 4.0 , pd .NA ],
487
+ [pd .Timestamp ("1950-01-07" ), "C" , np .nan , pd .NA ],
488
+ [pd .Timestamp ("1950-01-08" ), "C" , 3.0 , pd .NA ],
489
+ [pd .Timestamp ("1950-01-09" ), "C" , 4.0 , pd .NA ],
486
490
]
491
+
492
+ expected = DataFrame (expected_data , columns = ["date" , "panel" , "data" , "state" ])
487
493
expected = expected .set_index (["date" , "panel" ])
488
494
489
495
result = frame .merge (other , how = "left" , on = ["date" , "panel" ])
0 commit comments