@@ -549,41 +549,6 @@ def astype_intsafe(ndarray[object] arr, new_dtype):
549549 return result
550550
551551
552- @ cython.wraparound (False )
553- @ cython.boundscheck (False )
554- def astype_unicode (arr: ndarray , skipna: bool = False ) -> ndarray[object]:
555- """
556- Convert all elements in an array to unicode.
557-
558- Parameters
559- ----------
560- arr : ndarray
561- The array whose elements we are casting.
562- skipna : bool , default False
563- Whether or not to coerce nulls to their stringified form
564- (e.g. NaN becomes 'nan').
565-
566- Returns
567- -------
568- casted_arr : ndarray
569- A new array with the input array's elements casted.
570- """
571- cdef:
572- object arr_i
573- Py_ssize_t i , n = arr.size
574- ndarray[object] result = np.empty(n, dtype = object )
575-
576- for i in range(n ):
577- arr_i = arr[i]
578-
579- if not (skipna and checknull(arr_i)):
580- arr_i = unicode (arr_i)
581-
582- result[i] = arr_i
583-
584- return result
585-
586-
587552@ cython.wraparound (False )
588553@ cython.boundscheck (False )
589554def astype_str (arr: ndarray , skipna: bool = False ) -> ndarray[object]:
@@ -1321,10 +1286,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
13211286 if is_string_array(values, skipna = skipna):
13221287 return ' string'
13231288
1324- elif isinstance (val, unicode ):
1325- if is_unicode_array(values, skipna = skipna):
1326- return ' unicode'
1327-
13281289 elif isinstance (val, bytes):
13291290 if is_bytes_array(values, skipna = skipna):
13301291 return ' bytes'
@@ -1596,22 +1557,6 @@ cpdef bint is_string_array(ndarray values, bint skipna=False):
15961557 return validator.validate(values)
15971558
15981559
1599- cdef class UnicodeValidator(Validator):
1600- cdef inline bint is_value_typed(self , object value) except - 1 :
1601- return isinstance (value, unicode )
1602-
1603- cdef inline bint is_array_typed(self ) except - 1 :
1604- return issubclass (self .dtype.type, np.unicode_)
1605-
1606-
1607- cdef bint is_unicode_array(ndarray values, bint skipna = False ):
1608- cdef:
1609- UnicodeValidator validator = UnicodeValidator(len (values),
1610- values.dtype,
1611- skipna = skipna)
1612- return validator.validate(values)
1613-
1614-
16151560cdef class BytesValidator(Validator):
16161561 cdef inline bint is_value_typed(self , object value) except - 1 :
16171562 return isinstance (value, bytes)
0 commit comments