Skip to content

Commit dcb77b6

Browse files
committed
No need for _object_compat
1 parent 78bc224 commit dcb77b6

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626

2727
class ArrowStringArrayMixin:
28-
# _object_compat specifies whether we should 1) attempt to match behaviors
29-
# of the object-backed StringDtype and 2) fall back to object-based
30-
# computation for cases that pyarrow does not support natively.
31-
_object_compat = False
3228
_pa_array: Sized
3329

3430
def __init__(self, *args, **kwargs) -> None:
@@ -114,17 +110,9 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
114110
result = pc.starts_with(self._pa_array, pattern=pat)
115111
else:
116112
if len(pat) == 0:
117-
if self._object_compat:
118-
# mimic existing behaviour of string extension array
119-
# and python string method
120-
result = pa.array(
121-
np.zeros(len(self._pa_array), dtype=np.bool_),
122-
mask=isna(self._pa_array),
123-
)
124-
else:
125-
# For empty tuple, pd.StringDtype() returns null for missing values
126-
# and false for valid values.
127-
result = pc.if_else(pc.is_null(self._pa_array), None, False)
113+
# For empty tuple we return null for missing values and False
114+
# for valid values.
115+
result = pc.if_else(pc.is_null(self._pa_array), None, False)
128116
else:
129117
result = pc.starts_with(self._pa_array, pattern=pat[0])
130118

@@ -139,17 +127,9 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
139127
result = pc.ends_with(self._pa_array, pattern=pat)
140128
else:
141129
if len(pat) == 0:
142-
if self._object_compat:
143-
# mimic existing behaviour of string extension array
144-
# and python string method
145-
result = pa.array(
146-
np.zeros(len(self._pa_array), dtype=np.bool_),
147-
mask=isna(self._pa_array),
148-
)
149-
else:
150-
# For empty tuple, pd.StringDtype() returns null for missing values
151-
# and false for valid values.
152-
result = pc.if_else(pc.is_null(self._pa_array), None, False)
130+
# For empty tuple we return null for missing values and False
131+
# for valid values.
132+
result = pc.if_else(pc.is_null(self._pa_array), None, False)
153133
else:
154134
result = pc.ends_with(self._pa_array, pattern=pat[0])
155135

0 commit comments

Comments
 (0)