25
25
26
26
27
27
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
32
28
_pa_array : Sized
33
29
34
30
def __init__ (self , * args , ** kwargs ) -> None :
@@ -114,17 +110,9 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
114
110
result = pc .starts_with (self ._pa_array , pattern = pat )
115
111
else :
116
112
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 )
128
116
else :
129
117
result = pc .starts_with (self ._pa_array , pattern = pat [0 ])
130
118
@@ -139,17 +127,9 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
139
127
result = pc .ends_with (self ._pa_array , pattern = pat )
140
128
else :
141
129
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 )
153
133
else :
154
134
result = pc .ends_with (self ._pa_array , pattern = pat [0 ])
155
135
0 commit comments