File tree Expand file tree Collapse file tree 3 files changed +4
-14
lines changed
Expand file tree Collapse file tree 3 files changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -1626,7 +1626,7 @@ def _dtype_to_stata_type(dtype, column):
16261626 elif dtype .type == np .object_ : # try to coerce it to the biggest string
16271627 # not memory efficient, what else could we
16281628 # do?
1629- itemsize = max_len_string_array (column .values )
1629+ itemsize = max_len_string_array (com . _ensure_object ( column .values ) )
16301630 return chr (max (itemsize , 1 ))
16311631 elif dtype == np .float64 :
16321632 return chr (255 )
@@ -1664,7 +1664,7 @@ def _dtype_to_default_stata_fmt(dtype, column):
16641664 if not (inferred_dtype in ('string' , 'unicode' )
16651665 or len (column ) == 0 ):
16661666 raise ValueError ('Writing general object arrays is not supported' )
1667- itemsize = max_len_string_array (column .values )
1667+ itemsize = max_len_string_array (com . _ensure_object ( column .values ) )
16681668 if itemsize > 244 :
16691669 raise ValueError (excessive_string_length_error % column .name )
16701670 return "%" + str (max (itemsize , 1 )) + "s"
Original file line number Diff line number Diff line change @@ -903,21 +903,11 @@ def clean_index_list(list obj):
903903ctypedef fused pandas_t:
904904 str
905905 unicode
906- float32_t
907- float64_t
908- uint8_t
909- uint16_t
910- uint32_t
911- uint64_t
912- int8_t
913- int16_t
914- int32_t
915- int64_t
916906
917907
918908@ cython.boundscheck (False )
919909@ cython.wraparound (False )
920- def max_len_string_array (pandas_t[:] arr ):
910+ cpdef Py_ssize_t max_len_string_array(pandas_t[:] arr):
921911 """ return the maximum size of elements in a 1-dim string array """
922912 cdef:
923913 Py_ssize_t i, m = 0 , l = 0 , length = arr.shape[0 ]
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def test_max_len_string_array(self):
1616 self .assertTrue (max_len_string_array (arr ),3 )
1717
1818 # unicode
19- arr = arr .astype ('U' )
19+ arr = arr .astype ('U' ). astype ( object )
2020 self .assertTrue (max_len_string_array (arr ),3 )
2121
2222class TestIsscalar (tm .TestCase ):
You can’t perform that action at this time.
0 commit comments