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 :
@@ -110,17 +106,9 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
110
106
result = pc .starts_with (self ._pa_array , pattern = pat )
111
107
else :
112
108
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 )
124
112
else :
125
113
result = pc .starts_with (self ._pa_array , pattern = pat [0 ])
126
114
@@ -135,17 +123,9 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
135
123
result = pc .ends_with (self ._pa_array , pattern = pat )
136
124
else :
137
125
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 )
149
129
else :
150
130
result = pc .ends_with (self ._pa_array , pattern = pat [0 ])
151
131
0 commit comments