Skip to content

Commit 30d802a

Browse files
Abby VeCaseyAbby VeCasey
Abby VeCasey
authored and
Abby VeCasey
committed
ascii3
1 parent bea1cfa commit 30d802a

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

pandas/core/arrays/_arrow_string_mixins.py

-47
Original file line numberDiff line numberDiff line change
@@ -252,58 +252,11 @@ def _str_isalnum(self):
252252
def _str_isalpha(self):
253253
result = pc.utf8_is_alpha(self._pa_array)
254254
return self._convert_bool_result(result)
255-
256-
257-
# def _str_isascii(self):
258-
# if hasattr(pa.compute, "ascii_is_ascii"):
259-
# # If PyArrow adds support in the future, use it
260-
# return pa.compute.ascii_is_ascii(self._data)
261-
# else:
262-
# # Fallback: Use Python's native str.isascii() on each element
263-
# return [
264-
# s.isascii() if isinstance(s, str) else None
265-
# for s in self.to_pylist()
266-
# ]
267-
268-
# def _str_isascii(self):
269-
# pylist = [
270-
# s.isascii() if isinstance(s, str) else None
271-
# for s in self._pa_array.to_pylist()
272-
# ]
273-
274-
# result = pa.array(pylist, type=pa.bool_())
275-
# return self._convert_bool_result(result)
276-
277-
# def _str_isascii(self):
278-
# if isinstance(self, str):
279-
# result = all(ord(char) < 128 for char in self)
280-
# return self._convert_bool_result(result)
281-
# return False
282255

283256
def _str_isascii(self):
284-
# Check if the array is of string type (or if the implementation should handle it) # Apply the isascii check element-wise using PyArrow's compute functions
285257
result = pc.string_is_ascii(self._pa_array)
286-
287-
# Convert the result to the appropriate format (e.g., PyArrow BooleanArray)
288258
return self._convert_bool_result(result)
289259

290-
# def _str_isascii(self):
291-
# # Handle the case where self might be a pandas StringArray or similar
292-
# # Check if each value is not NA, and is a string of length 1 (single character)
293-
# def isna(value):
294-
# return value is None
295-
296-
# def check_ascii(value):
297-
# if isna(value):
298-
# return False # Or return True depending on how you want to handle NA values
299-
# if len(value) != 1:
300-
# raise ValueError(f"Expected a string of length 1, got: {value}")
301-
# return ord(value) < 128
302-
303-
# # Apply the check to each element in `self` (assuming `self` is iterable like pandas Series)
304-
# result = all(check_ascii(char) for char in self)
305-
# return self._convert_bool_result(result)
306-
307260
def _str_isdecimal(self):
308261
result = pc.utf8_is_decimal(self._pa_array)
309262
return self._convert_bool_result(result)

0 commit comments

Comments
 (0)