@@ -486,17 +486,15 @@ def test_concat_categorical(self):
486
486
s1 = Series ([3 , 2 ], dtype = "category" )
487
487
s2 = Series ([2 , 1 ], dtype = "category" )
488
488
489
- exp = Series ([3 , 2 , 2 , 1 ], dtype = "category" ) # should remain category
489
+ exp = Series ([3 , 2 , 2 , 1 ])
490
490
tm .assert_series_equal (pd .concat ([s1 , s2 ], ignore_index = True ), exp )
491
491
tm .assert_series_equal (s1 ._append (s2 , ignore_index = True ), exp )
492
492
493
493
# completely different categories (same dtype) => not-category
494
- s1 = Series ([10.0 , 11.0 , np .nan ], dtype = "category" )
495
- s2 = Series ([np .nan , 1.0 , 3.0 , 2.0 ], dtype = "category" )
494
+ s1 = Series ([10 , 11 , np .nan ], dtype = "category" )
495
+ s2 = Series ([np .nan , 1 , 3 , 2 ], dtype = "category" )
496
496
497
- exp = Series ([10 , 11 , np .nan , np .nan , 1 , 3 , 2 ], dtype = np .float64 ).astype (
498
- "category"
499
- )
497
+ exp = Series ([10 , 11 , np .nan , np .nan , 1 , 3 , 2 ], dtype = np .float64 )
500
498
tm .assert_series_equal (pd .concat ([s1 , s2 ], ignore_index = True ), exp )
501
499
tm .assert_series_equal (s1 ._append (s2 , ignore_index = True ), exp )
502
500
@@ -696,7 +694,7 @@ def test_concat_categorical_empty(self):
696
694
697
695
s1 = Series ([], dtype = "category" )
698
696
s2 = Series ([1 , 2 ], dtype = "category" )
699
- exp = s2
697
+ exp = s2 . astype ( object )
700
698
tm .assert_series_equal (pd .concat ([s1 , s2 ], ignore_index = True ), exp )
701
699
tm .assert_series_equal (s1 ._append (s2 , ignore_index = True ), exp )
702
700
@@ -745,13 +743,7 @@ def test_categorical_concat_append(self):
745
743
df_different_categories = DataFrame ({"cats" : cat3 , "vals" : vals3 })
746
744
747
745
res = pd .concat ([df , df_different_categories ], ignore_index = True )
748
- exp = DataFrame (
749
- {
750
- "cats" : Categorical (list ("abab" ), categories = ["a" , "b" , "c" ]),
751
- "vals" : [1 , 2 , 1 , 2 ],
752
- }
753
- ) # I do not agree with the test made in #37243
754
-
746
+ exp = DataFrame ({"cats" : list ("abab" ), "vals" : [1 , 2 , 1 , 2 ]})
755
747
tm .assert_frame_equal (res , exp )
756
748
757
749
res = df ._append (df_different_categories , ignore_index = True )
0 commit comments