Skip to content

Commit

Permalink
API: fall back to object dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Aug 27, 2024
1 parent 767857e commit ee6561b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandas/core/arrays/_arrow_string_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def _str_pad(
elif side == "both":
if pa_version_under17p0:
# GH#59624 fall back to object dtype
return super()._str_pad(width, side, fillchar)
from pandas import array

obj_arr = self.astype(object, copy=False) # type: ignore[attr-defined]
obj = array(obj_arr, dtype=object)
result = obj._str_pad(width, side, fillchar) # type: ignore[attr-defined]
return type(self)._from_sequence(result, dtype=self.dtype) # type: ignore[attr-defined]
else:
# GH#54792
pa_pad = partial(pc.utf8_center, lean_left_on_odd_padding=False)
Expand Down

0 comments on commit ee6561b

Please sign in to comment.