@@ -549,41 +549,6 @@ def astype_intsafe(ndarray[object] arr, new_dtype):
549
549
return result
550
550
551
551
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
-
587
552
@ cython.wraparound (False )
588
553
@ cython.boundscheck (False )
589
554
def astype_str (arr: ndarray , skipna: bool = False ) -> ndarray[object]:
@@ -1321,10 +1286,6 @@ def infer_dtype(value: object, skipna: object=None) -> str:
1321
1286
if is_string_array(values, skipna = skipna):
1322
1287
return ' string'
1323
1288
1324
- elif isinstance (val, unicode ):
1325
- if is_unicode_array(values, skipna = skipna):
1326
- return ' unicode'
1327
-
1328
1289
elif isinstance (val, bytes):
1329
1290
if is_bytes_array(values, skipna = skipna):
1330
1291
return ' bytes'
@@ -1596,22 +1557,6 @@ cpdef bint is_string_array(ndarray values, bint skipna=False):
1596
1557
return validator.validate(values)
1597
1558
1598
1559
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
-
1615
1560
cdef class BytesValidator(Validator):
1616
1561
cdef inline bint is_value_typed(self , object value) except - 1 :
1617
1562
return isinstance (value, bytes)
0 commit comments