Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix Series(extension array) + extension array values addition #22479

Merged
merged 6 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ ExtensionType Changes
- :meth:`Series.combine()` with scalar argument now works for any function type (:issue:`21248`)
- :meth:`Series.astype` and :meth:`DataFrame.astype` now dispatch to :meth:`ExtensionArray.astype` (:issue:`21185:`).
- Added :meth:`pandas.api.types.register_extension_dtype` to register an extension type with pandas (:issue:`22664`)
Copy link
Contributor

Choose a reason for hiding this comment

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

W can remove this I think... integerArray is new in 0.24

- Bug in :meth:`pandas.core.ops.dispatch_to_extension_op` where addition of ``Series`` of ``IntegerArray`` and ``IntegerArray`` values raise runtime exception (:issue `22478`)

.. _whatsnew_0240.api.incompatibilities:

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ def dispatch_to_extension_op(op, left, right):
new_right = [new_right]
new_right = list(new_right)
elif is_extension_array_dtype(right) and type(left) != type(right):
new_right = list(new_right)
new_right = list(right)
else:
new_right = right

Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ def test_cross_type_arithmetic():
tm.assert_series_equal(result, expected)


def test_arith_extension_array_values():
Copy link
Member

Choose a reason for hiding this comment

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

Can you move the test to pandas/tests/extension/base/ops.py, as this is not a specific failure for IntegerArray, it is relevant for all extension types.

# GH 22478
s = pd.Series([1, 2, 3], dtype='Int64')
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the issue as a comment

result = s + s.values
expected = pd.Series([2, 4, 6], dtype='Int64')
tm.assert_series_equal(result, expected)


def test_groupby_mean_included():
df = pd.DataFrame({
"A": ['a', 'b', 'b'],
Expand Down