From 08691d40324c5b76857b31d8090c256da74a93f1 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 27 Aug 2024 07:38:20 -0700 Subject: [PATCH] No need for _object_compat --- pandas/core/arrays/_arrow_string_mixins.py | 32 ++++------------------ 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/pandas/core/arrays/_arrow_string_mixins.py b/pandas/core/arrays/_arrow_string_mixins.py index c60adf878f1285..1062626eda7b84 100644 --- a/pandas/core/arrays/_arrow_string_mixins.py +++ b/pandas/core/arrays/_arrow_string_mixins.py @@ -25,10 +25,6 @@ class ArrowStringArrayMixin: - # _object_compat specifies whether we should 1) attempt to match behaviors - # of the object-backed StringDtype and 2) fall back to object-based - # computation for cases that pyarrow does not support natively. - _object_compat = False _pa_array: Sized def __init__(self, *args, **kwargs) -> None: @@ -110,17 +106,9 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None): result = pc.starts_with(self._pa_array, pattern=pat) else: if len(pat) == 0: - if self._object_compat: - # mimic existing behaviour of string extension array - # and python string method - result = pa.array( - np.zeros(len(self._pa_array), dtype=np.bool_), - mask=isna(self._pa_array), - ) - else: - # For empty tuple, pd.StringDtype() returns null for missing values - # and false for valid values. - result = pc.if_else(pc.is_null(self._pa_array), None, False) + # For empty tuple we return null for missing values and False + # for valid values. + result = pc.if_else(pc.is_null(self._pa_array), None, False) else: result = pc.starts_with(self._pa_array, pattern=pat[0]) @@ -135,17 +123,9 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None): result = pc.ends_with(self._pa_array, pattern=pat) else: if len(pat) == 0: - if self._object_compat: - # mimic existing behaviour of string extension array - # and python string method - result = pa.array( - np.zeros(len(self._pa_array), dtype=np.bool_), - mask=isna(self._pa_array), - ) - else: - # For empty tuple, pd.StringDtype() returns null for missing values - # and false for valid values. - result = pc.if_else(pc.is_null(self._pa_array), None, False) + # For empty tuple we return null for missing values and False + # for valid values. + result = pc.if_else(pc.is_null(self._pa_array), None, False) else: result = pc.ends_with(self._pa_array, pattern=pat[0])