1- from pandas import Series
1+ from pandas import (
2+ NA ,
3+ Series ,
4+ )
25import pandas ._testing as tm
36
47
58class TestCombine :
69 def test_combine_scalar (self ):
710 # GH#21248
8- # Note - combine() with another Series is tested elsewhere because
9- # it is used when testing operators
1011 ser = Series ([i * 10 for i in range (5 )])
1112 result = ser .combine (3 , lambda x , y : x + y )
1213 expected = Series ([i * 10 + 3 for i in range (5 )])
@@ -15,3 +16,13 @@ def test_combine_scalar(self):
1516 result = ser .combine (22 , lambda x , y : min (x , y ))
1617 expected = Series ([min (i * 10 , 22 ) for i in range (5 )])
1718 tm .assert_series_equal (result , expected )
19+
20+ def test_combine_series (self ):
21+ # GH#31899
22+ # Note - combine() with another Series is also tested elsewhere because
23+ # it is used when testing operators
24+ s1 = Series ([91 , NA , 94 ], dtype = "Int8" )
25+ s2 = Series ([91 , NA , 11 ], dtype = "Int8" )
26+ result = s1 .combine (s2 , lambda x , y : x + y )
27+ expected = Series ([- 74 , NA , 105 ], dtype = "Int8" ) # dtype should be preserved
28+ tm .assert_series_equal (result , expected )
0 commit comments