Skip to content

Commit 0108553

Browse files
committed
BUG: extension array add values of itself cause cause runtime exception pandas-dev#22478
1 parent 2be2ba5 commit 0108553

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ def dispatch_to_extension_op(op, left, right):
11511151
new_right = [new_right]
11521152
new_right = list(new_right)
11531153
elif is_extension_array_dtype(right) and type(left) != type(right):
1154-
new_right = list(new_right)
1154+
new_right = list(right)
11551155
else:
11561156
new_right = right
11571157

pandas/tests/extension/integer/test_integer.py

+8
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,14 @@ def test_cross_type_arithmetic():
767767
tm.assert_series_equal(result, expected)
768768

769769

770+
def test_arith_extension_array_values():
771+
772+
s = pd.Series([1, 2, 3], dtype='Int64')
773+
result = s + s.values
774+
expected = pd.Series([2, 4, 6], dtype='Int64')
775+
tm.assert_series_equal(result, expected)
776+
777+
770778
def test_groupby_mean_included():
771779
df = pd.DataFrame({
772780
"A": ['a', 'b', 'b'],

0 commit comments

Comments
 (0)