Skip to content

Commit

Permalink
ascii3
Browse files Browse the repository at this point in the history
  • Loading branch information
Abby VeCasey authored and Abby VeCasey committed Dec 9, 2024
1 parent e37a6b1 commit 1647cf9
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions pandas/core/arrays/_arrow_string_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1647cf9

Please sign in to comment.