@@ -1515,7 +1515,7 @@ def test_self_join_multiple_categories(self):
1515
1515
1516
1516
assert_frame_equal (result , df )
1517
1517
1518
- def test_categorical_dates (self ):
1518
+ def test_dtype_on_categorical_dates (self ):
1519
1519
# GH 16900
1520
1520
# dates should not be coerced to ints
1521
1521
@@ -1533,14 +1533,21 @@ def test_categorical_dates(self):
1533
1533
)
1534
1534
df2 ['date' ] = df2 ['date' ].astype ('category' )
1535
1535
1536
- result = pd .merge (df , df2 , how = 'outer' , on = ['date' ])
1537
- assert result .shape == (3 , 3 )
1538
- assert result ['date' ].iloc [0 ] == pd .Timestamp ('2001-01-01' )
1539
- assert result ['date' ].iloc [- 1 ] == pd .Timestamp ('2001-01-03' )
1536
+ expected_outer = pd .DataFrame ([
1537
+ [pd .Timestamp ('2001-01-01' ), 1.1 , 1.3 ],
1538
+ [pd .Timestamp ('2001-01-02' ), 1.3 , np .nan ],
1539
+ [pd .Timestamp ('2001-01-03' ), np .nan , 1.4 ]],
1540
+ columns = ['date' , 'num2' , 'num4' ]
1541
+ )
1542
+ result_outer = pd .merge (df , df2 , how = 'outer' , on = ['date' ])
1543
+ assert_frame_equal (result_outer , expected_outer )
1540
1544
1545
+ expected_inner = pd .DataFrame (
1546
+ [[pd .Timestamp ('2001-01-01' ), 1.1 , 1.3 ]],
1547
+ columns = ['date' , 'num2' , 'num4' ]
1548
+ )
1541
1549
result_inner = pd .merge (df , df2 , how = 'inner' , on = ['date' ])
1542
- assert result_inner .shape == (1 , 3 )
1543
- assert result_inner ['date' ].iloc [- 1 ] == pd .Timestamp ('2001-01-01' )
1550
+ assert_frame_equal (result_inner , expected_inner )
1544
1551
1545
1552
1546
1553
@pytest .fixture
0 commit comments