Skip to content

Commit

Permalink
REF: re-use ArrowEA methods in ArrowStringArray
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Sep 4, 2024
1 parent 7b6e4f3 commit ab0c761
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions pandas/core/arrays/string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
ArrayLike,
AxisInt,
Dtype,
Scalar,
Self,
npt,
)
Expand Down Expand Up @@ -295,6 +294,19 @@ def astype(self, dtype, copy: bool = True):
_str_startswith = ArrowStringArrayMixin._str_startswith
_str_endswith = ArrowStringArrayMixin._str_endswith
_str_pad = ArrowStringArrayMixin._str_pad
_str_match = ArrowExtensionArray._str_match
_str_fullmatch = ArrowExtensionArray._str_fullmatch
_str_lower = ArrowExtensionArray._str_lower
_str_upper = ArrowExtensionArray._str_upper
_str_strip = ArrowExtensionArray._str_strip
_str_lstrip = ArrowExtensionArray._str_lstrip
_str_rstrip = ArrowExtensionArray._str_rstrip
_str_removesuffix = ArrowStringArrayMixin._str_removesuffix
_str_get = ArrowStringArrayMixin._str_get
_str_capitalize = ArrowStringArrayMixin._str_capitalize
_str_title = ArrowStringArrayMixin._str_title
_str_swapcase = ArrowStringArrayMixin._str_swapcase
_str_slice_replace = ArrowStringArrayMixin._str_slice_replace

def _str_contains(
self, pat, case: bool = True, flags: int = 0, na=np.nan, regex: bool = True
Expand Down Expand Up @@ -354,15 +366,6 @@ def _str_len(self):
result = pc.utf8_length(self._pa_array)
return self._convert_int_result(result)

_str_match = ArrowExtensionArray._str_match
_str_fullmatch = ArrowExtensionArray._str_fullmatch
_str_lower = ArrowExtensionArray._str_lower
_str_upper = ArrowExtensionArray._str_upper
_str_strip = ArrowExtensionArray._str_strip
_str_lstrip = ArrowExtensionArray._str_lstrip
_str_rstrip = ArrowExtensionArray._str_rstrip
_str_removesuffix = ArrowStringArrayMixin._str_removesuffix

def _str_removeprefix(self, prefix: str):
if not pa_version_under13p0:
return ArrowExtensionArray._str_removeprefix(self, prefix)
Expand Down Expand Up @@ -471,8 +474,3 @@ def _cmp_method(self, other, op):

class ArrowStringArrayNumpySemantics(ArrowStringArray):
_na_value = np.nan
_str_get = ArrowStringArrayMixin._str_get
_str_capitalize = ArrowStringArrayMixin._str_capitalize
_str_title = ArrowStringArrayMixin._str_title
_str_swapcase = ArrowStringArrayMixin._str_swapcase
_str_slice_replace = ArrowStringArrayMixin._str_slice_replace

0 comments on commit ab0c761

Please sign in to comment.