Skip to content

Commit 4def7fa

Browse files
authored
Fix type check error by avoiding copy() in ArrowStringArrayMixin
1 parent 2f302d4 commit 4def7fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ def _str_swapcase(self) -> Self:
204204

205205
def _str_removeprefix(self, prefix: str):
206206
if prefix == "":
207-
return self.copy()
207+
return self._from_pyarrow_array(self._pa_array)
208208
starts_with = pc.starts_with(self._pa_array, pattern=prefix)
209209
removed = pc.utf8_slice_codeunits(self._pa_array, len(prefix))
210210
result = pc.if_else(starts_with, removed, self._pa_array)
211211
return self._from_pyarrow_array(result)
212212

213213
def _str_removesuffix(self, suffix: str):
214214
if suffix == "":
215-
return self.copy()
215+
return self._from_pyarrow_array(self._pa_array)
216216
ends_with = pc.ends_with(self._pa_array, pattern=suffix)
217217
removed = pc.utf8_slice_codeunits(self._pa_array, 0, stop=-len(suffix))
218218
result = pc.if_else(ends_with, removed, self._pa_array)

0 commit comments

Comments
 (0)