From ab0c7611b3adce9de9d5dfa628a2bb4b2f94b541 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 4 Sep 2024 07:58:12 -0700 Subject: [PATCH] REF: re-use ArrowEA methods in ArrowStringArray --- pandas/core/arrays/string_arrow.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index 6611ca202f960b..2db10bdbd4d489 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -56,7 +56,6 @@ ArrayLike, AxisInt, Dtype, - Scalar, Self, npt, ) @@ -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 @@ -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) @@ -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