Skip to content

Commit

Permalink
CLN: removed unnecessary type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronoJon committed Oct 8, 2023
1 parent e55a1e4 commit 6da7131
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pandas/core/arrays/string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _str_contains(
def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
if isinstance(pat, str):
result = pc.starts_with(self._pa_array, pattern=pat)
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
else:
if len(pat) == 0:
# mimic existing behaviour of string extension array
# and python string method
Expand All @@ -345,8 +345,6 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):

for p in pat[1:]:
result = pc.or_(result, pc.starts_with(self._pa_array, pattern=p))
else:
raise TypeError("pat must be str or tuple[str, ...]")
if not isna(na):
result = result.fill_null(na)
result = self._result_converter(result)
Expand All @@ -357,7 +355,7 @@ def _str_startswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):
if isinstance(pat, str):
result = pc.ends_with(self._pa_array, pattern=pat)
elif isinstance(pat, tuple) and all(isinstance(x, str) for x in pat):
else:
if len(pat) == 0:
# mimic existing behaviour of string extension array
# and python string method
Expand All @@ -369,8 +367,6 @@ def _str_endswith(self, pat: str | tuple[str, ...], na: Scalar | None = None):

for p in pat[1:]:
result = pc.or_(result, pc.ends_with(self._pa_array, pattern=p))
else:
raise TypeError("pat must be of type str or tuple[str, ...]")
if not isna(na):
result = result.fill_null(na)
result = self._result_converter(result)
Expand Down

0 comments on commit 6da7131

Please sign in to comment.