From 6da713173217e3964541f3d50075a91d85daeeae Mon Sep 17 00:00:00 2001 From: ChronoJon Date: Sun, 8 Oct 2023 20:42:33 +0000 Subject: [PATCH] CLN: removed unnecessary type checks --- pandas/core/arrays/string_arrow.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index 0345e98143e627..e77f05a304ad06 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -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 @@ -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) @@ -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 @@ -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)