Skip to content

Commit 08691d4

Browse files
committed
No need for _object_compat
1 parent 310bf82 commit 08691d4

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:
@@ -110,17 +106,9 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
110106
result = pc.starts_with(self._pa_array, pattern=pat)
111107
else:
112108
if len(pat) == 0:
113-
if self._object_compat:
114-
# mimic existing behaviour of string extension array
115-
# and python string method
116-
result = pa.array(
117-
np.zeros(len(self._pa_array), dtype=np.bool_),
118-
mask=isna(self._pa_array),
119-
)
120-
else:
121-
# For empty tuple, pd.StringDtype() returns null for missing values
122-
# and false for valid values.
123-
result = pc.if_else(pc.is_null(self._pa_array), None, False)
109+
# For empty tuple we return null for missing values and False
110+
# for valid values.
111+
result = pc.if_else(pc.is_null(self._pa_array), None, False)
124112
else:
125113
result = pc.starts_with(self._pa_array, pattern=pat[0])
126114

@@ -135,17 +123,9 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
135123
result = pc.ends_with(self._pa_array, pattern=pat)
136124
else:
137125
if len(pat) == 0:
138-
if self._object_compat:
139-
# mimic existing behaviour of string extension array
140-
# and python string method
141-
result = pa.array(
142-
np.zeros(len(self._pa_array), dtype=np.bool_),
143-
mask=isna(self._pa_array),
144-
)
145-
else:
146-
# For empty tuple, pd.StringDtype() returns null for missing values
147-
# and false for valid values.
148-
result = pc.if_else(pc.is_null(self._pa_array), None, False)
126+
# For empty tuple we return null for missing values and False
127+
# for valid values.
128+
result = pc.if_else(pc.is_null(self._pa_array), None, False)
149129
else:
150130
result = pc.ends_with(self._pa_array, pattern=pat[0])
151131

0 commit comments

Comments
 (0)