Skip to content

BUG: setitem with boolean mask and series as value is broken for Series with EA type #37676

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

Merged
merged 12 commits into from
Nov 17, 2020
8 changes: 8 additions & 0 deletions pandas/tests/series/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
NaT,
Series,
Timestamp,
array,
date_range,
period_range,
)
Expand Down Expand Up @@ -126,6 +127,13 @@ def test_setitem_boolean_different_order(self, string_series):

tm.assert_series_equal(copy, expected)

def test_setitem_boolean_ea_type(self):
# GH: 26468
s = Series(array([5, 6, 7, 8], dtype="Int64"))
s[s > 6] = Series(range(4), dtype="Int64")
Copy link
Member

Choose a reason for hiding this comment

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

generally looks good, couple of nitpicks: can you import array as pd_array, name this ser instead of s (doesnt have to be ser, the important thing is to avoid 1-letter variable names), instead of "ea_type" use "Int64_values" (or better yet, parametrize over nullable int dtypes)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks for the tips

expected = Series([5, 6, 2, 3], dtype="Int64")
tm.assert_series_equal(s, expected)


class TestSetitemViewCopySemantics:
def test_setitem_invalidates_datetime_index_freq(self):
Expand Down