Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions pandas/tests/series/methods/test_combine.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from pandas import Series
from pandas import (
NA,
Series,
)
import pandas._testing as tm


class TestCombine:
def test_combine_scalar(self):
# GH#21248
# Note - combine() with another Series is tested elsewhere because
# it is used when testing operators
ser = Series([i * 10 for i in range(5)])
result = ser.combine(3, lambda x, y: x + y)
expected = Series([i * 10 + 3 for i in range(5)])
Expand All @@ -15,3 +16,13 @@ def test_combine_scalar(self):
result = ser.combine(22, lambda x, y: min(x, y))
expected = Series([min(i * 10, 22) for i in range(5)])
tm.assert_series_equal(result, expected)

def test_combine_series(self):
# GH#31899
# Note - combine() with another Series is also tested elsewhere because
# it is used when testing operators
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this comment moved?

s1 = Series([91, NA, 94], dtype="Int8")
s2 = Series([91, NA, 11], dtype="Int8")
result = s1.combine(s2, lambda x, y: x + y)
expected = Series([-74, NA, 105], dtype="Int8") # dtype should be preserved
tm.assert_series_equal(result, expected)
Loading