Skip to content

Commit e733bfb

Browse files
authored
fix for failing tests
1 parent 9a526ea commit e733bfb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,17 @@ def _str_title(self) -> Self:
202202
def _str_swapcase(self) -> Self:
203203
return self._from_pyarrow_array(pc.utf8_swapcase(self._pa_array))
204204
def _str_removeprefix(self, prefix: str):
205+
if prefix == "":
206+
return self
205207
starts_with = pc.starts_with(self._pa_array, pattern=prefix)
206208
removed = pc.utf8_slice_codeunits(self._pa_array, len(prefix))
207209
result = pc.if_else(starts_with, removed, self._pa_array)
208210
return self._from_pyarrow_array(result)
209211

210212

211213
def _str_removesuffix(self, suffix: str):
214+
if suffix == "":
215+
return self
212216
ends_with = pc.ends_with(self._pa_array, pattern=suffix)
213217
removed = pc.utf8_slice_codeunits(self._pa_array, 0, stop=-len(suffix))
214218
result = pc.if_else(ends_with, removed, self._pa_array)
@@ -217,6 +221,7 @@ def _str_removesuffix(self, suffix: str):
217221

218222

219223

224+
220225
def _str_startswith(
221226
self, pat: str | tuple[str, ...], na: Scalar | lib.NoDefault = lib.no_default
222227
):

0 commit comments

Comments
 (0)