Skip to content

[ArrowStringArray] fix test_repeat_with_null #41001

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 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions pandas/core/strings/object_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def scalar_rep(x):
return self._str_map(scalar_rep, dtype=str)
else:
from pandas.core.arrays.string_ import StringArray
from pandas.core.arrays.string_arrow import ArrowStringArray

def rep(x, r):
if x is libmissing.NA:
Expand All @@ -209,9 +210,9 @@ def rep(x, r):

repeats = np.asarray(repeats, dtype=object)
result = libops.vec_binop(np.asarray(self), repeats, rep)
if isinstance(self, StringArray):
if isinstance(self, (StringArray, ArrowStringArray)):
# Not going through map, so we have to do this here.
result = StringArray._from_sequence(result)
result = type(self)._from_sequence(result)
return result

def _str_match(
Expand Down
8 changes: 1 addition & 7 deletions pandas/tests/strings/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,8 @@ def test_repeat():
tm.assert_series_equal(rs, xp)


def test_repeat_with_null(nullable_string_dtype, request):
def test_repeat_with_null(nullable_string_dtype):
# GH: 31632

if nullable_string_dtype == "arrow_string":
reason = 'Attribute "dtype" are different'
mark = pytest.mark.xfail(reason=reason)
request.node.add_marker(mark)

ser = Series(["a", None], dtype=nullable_string_dtype)
result = ser.str.repeat([3, 4])
expected = Series(["aaa", None], dtype=nullable_string_dtype)
Expand Down