From 1647cf9f5a0fa818ac91d28c95445bc69e03c652 Mon Sep 17 00:00:00 2001 From: Abby VeCasey Date: Sun, 8 Dec 2024 22:58:40 -0500 Subject: [PATCH] ascii3 --- pandas/core/arrays/_arrow_string_mixins.py | 26 ++++------------------ 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/pandas/core/arrays/_arrow_string_mixins.py b/pandas/core/arrays/_arrow_string_mixins.py index 2c24378ab3409..ba886d91c70cf 100644 --- a/pandas/core/arrays/_arrow_string_mixins.py +++ b/pandas/core/arrays/_arrow_string_mixins.py @@ -277,29 +277,11 @@ def _str_isascii(self): # result = pa.array(pylist, type=pa.bool_()) # return self._convert_bool_result(result) - # def _str_isascii(self): - # if isinstance(self, str): - # result = all(ord(char) < 128 for char in self) - # return self._convert_bool_result(result) - # return None def _str_isascii(self): - pylist = [] - - for s in self._pa_array: - if s is None: # Handle None explicitly - pylist.append(None) # Keep None for PyArrow handling - elif isinstance(s, str): - # Check if the string is ASCII using ord() on each character - result = all(ord(char) < 128 for char in s) - pylist.append(result) - else: - pylist.append(None) # If it's not a string, append None - - # Convert the result back to a PyArrow array with nullable booleans (pa.bool_()) - result = pa.array(pylist, type=pa.bool_(), mask=[(v is None) for v in pylist]) - - # Use _convert_bool_result to process the result - return self._convert_bool_result(result) + if isinstance(self, str): + result = all(ord(char) < 128 for char in self) + return self._convert_bool_result(result) + return False # def _str_isascii(self):