File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -898,17 +898,17 @@ def clean_index_list(list obj):
898
898
899
899
@ cython.boundscheck (False )
900
900
@ cython.wraparound (False )
901
- def max_len_string_array (ndarray[ object , ndim = 1 ] arr):
901
+ def max_len_string_array (ndarray arr ):
902
902
""" return the maximum size of elements in a 1-dim string array """
903
903
cdef:
904
904
int i, m, l
905
- length = arr.shape[0 ]
905
+ int length = arr.shape[0 ]
906
906
object v
907
907
908
908
m = 0
909
909
for i from 0 <= i < length:
910
910
v = arr[i]
911
- if PyString_Check(v) or PyBytes_Check(v):
911
+ if PyString_Check(v) or PyBytes_Check(v) or PyUnicode_Check(v) :
912
912
l = len (v)
913
913
914
914
if l > m:
Original file line number Diff line number Diff line change 3
3
import numpy as np
4
4
5
5
import pandas as pd
6
- from pandas .lib import isscalar , item_from_zerodim
6
+ from pandas .lib import isscalar , item_from_zerodim , max_len_string_array
7
7
import pandas .util .testing as tm
8
8
from pandas .compat import u
9
9
10
+ class TestMisc (tm .TestCase ):
11
+
12
+ def test_max_len_string_array (self ):
13
+
14
+ arr = np .array (['foo' ,'b' ,np .nan ],dtype = 'object' )
15
+ self .assertTrue (max_len_string_array (arr ),3 )
16
+
17
+ # unicode
18
+ arr = arr .astype ('U' )
19
+ self .assertTrue (max_len_string_array (arr ),3 )
20
+
10
21
class TestIsscalar (tm .TestCase ):
11
22
def test_isscalar_builtin_scalars (self ):
12
23
self .assertTrue (isscalar (None ))
You can’t perform that action at this time.
0 commit comments