@@ -1515,7 +1515,7 @@ def test_self_join_multiple_categories(self):
15151515
15161516 assert_frame_equal (result , df )
15171517
1518- def test_categorical_dates (self ):
1518+ def test_dtype_on_categorical_dates (self ):
15191519 # GH 16900
15201520 # dates should not be coerced to ints
15211521
@@ -1533,14 +1533,21 @@ def test_categorical_dates(self):
15331533 )
15341534 df2 ['date' ] = df2 ['date' ].astype ('category' )
15351535
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 )
15401544
1545+ expected_inner = pd .DataFrame (
1546+ [[pd .Timestamp ('2001-01-01' ), 1.1 , 1.3 ]],
1547+ columns = ['date' , 'num2' , 'num4' ]
1548+ )
15411549 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 )
15441551
15451552
15461553@pytest .fixture
0 commit comments