Skip to content

Commit a1da54e

Browse files
authored
BUG: handle empty prefix in pyarrow-backed removeprefix
1 parent 74fb4f9 commit a1da54e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ def _str_swapcase(self) -> Self:
203203
return self._from_pyarrow_array(pc.utf8_swapcase(self._pa_array))
204204

205205
def _str_removeprefix(self, prefix: str):
206+
if prefix == "":
207+
return self
206208
starts_with = pc.starts_with(self._pa_array, pattern=prefix)
207209
removed = pc.utf8_slice_codeunits(self._pa_array, len(prefix))
208210
result = pc.if_else(starts_with, removed, self._pa_array)

0 commit comments

Comments
 (0)