@@ -630,11 +630,31 @@ def test_str_cat_align_mixed_inputs(self, join):
630
630
with pytest .raises (ValueError , match = rgx ):
631
631
s .str .cat ([t , z ], join = join )
632
632
633
- def test_str_cat_raises (self ):
634
- # non-strings hiding behind object dtype
635
- s = Series ([1 , 2 , 3 , 4 ], dtype = 'object' )
636
- with pytest .raises (TypeError , match = "unsupported operand type.*" ):
637
- s .str .cat (s )
633
+ @pytest .mark .parametrize ('box' , [Series , Index ])
634
+ @pytest .mark .parametrize ('other' , [Series , Index ])
635
+ def test_str_cat_all_na (self , box , other ):
636
+ # GH 24044
637
+
638
+ # check that all NaNs in caller / target work
639
+ s = Index (['a' , 'b' , 'c' , 'd' ])
640
+ s = s if box == Index else Series (s , index = s )
641
+ t = other ([np .nan ] * 4 , dtype = object )
642
+ # add index of s for alignment
643
+ t = t if other == Index else Series (t , index = s )
644
+
645
+ # all-NA target
646
+ if box == Series :
647
+ expected = Series ([np .nan ] * 4 , index = s .index , dtype = object )
648
+ else : # box == Index
649
+ expected = Index ([np .nan ] * 4 , dtype = object )
650
+ result = s .str .cat (t , join = 'left' )
651
+ assert_series_or_index_equal (result , expected )
652
+
653
+ # all-NA caller (only for Series)
654
+ if other == Series :
655
+ expected = Series ([np .nan ] * 4 , dtype = object , index = t .index )
656
+ result = t .str .cat (s , join = 'left' )
657
+ tm .assert_series_equal (result , expected )
638
658
639
659
def test_str_cat_special_cases (self ):
640
660
s = Series (['a' , 'b' , 'c' , 'd' ])
0 commit comments