Skip to content

Commit c9d96a7

Browse files
authored
Add test for combine between two series (#62674)
1 parent 0350b56 commit c9d96a7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
from pandas import Series
1+
from pandas import (
2+
NA,
3+
Series,
4+
)
25
import pandas._testing as tm
36

47

58
class 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,11 @@ 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+
s1 = Series([91, NA, 94], dtype="Int8")
23+
s2 = Series([91, NA, 11], dtype="Int8")
24+
result = s1.combine(s2, lambda x, y: x + y)
25+
expected = Series([-74, NA, 105], dtype="Int8") # dtype should be preserved
26+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)