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