def _convert_string_array(data, encoding, itemsize=None):
 if ((encoding is not None) and len(data)):
  data = Series(data.ravel()).str.encode(encoding).values.reshape(data.shape)
 if (itemsize is None):
  itemsize = lib.max_len_string_array(_ensure_object(data.ravel()))
 data = np.asarray(data, dtype=('S%d' % itemsize))
 return data

def _convert_string_array ( data , encoding , itemsize = None ) : if ( ( encoding is not None ) and len ( data ) ) : data = Series ( data . ravel ( ) ) . str . encode ( encoding ) . values . reshape ( data . shape ) if ( itemsize is None ) : itemsize = lib . max_len_string_array ( _ensure_object ( data . ravel ( ) ) ) data = np . asarray ( data , dtype = ( 'S%d' % itemsize ) ) return data
we take a string-like that is object dtype and coerce to a fixed size string type parameters data : a numpy array of object dtype encoding : none or string-encoding itemsize : integer .