def common_dtype(arrs):
 def dtype(arr):
  return getattr(arr, u'dtype', np.dtype(u'O'))
 np_types = (np.bool_, np.object_, np.number, np.character, np.void)
 uniq_types = set((tuple((issubclass(dtype(arr).type, np_type) for np_type in np_types)) for arr in arrs))
 if (len(uniq_types) > 1):
  incompat_types = [dtype(arr).name for arr in arrs]
  tme = MergeConflictError(u'Arrays have incompatible types {0}'.format(incompat_types))
  tme._incompat_types = incompat_types
  raise tme
 arrs = [np.empty(1, dtype=dtype(arr)) for arr in arrs]
 for (i, arr) in enumerate(arrs):
  if (arr.dtype.kind in (u'S', u'U')):
   arrs[i] = [((u'0' if (arr.dtype.kind == u'U') else '0') * arr.itemsize)]
 arr_common = np.array([arr[0] for arr in arrs])
 return arr_common.dtype.str

def common_dtype ( arrs ) : def dtype ( arr ) : return getattr ( arr , u'dtype' , np . dtype ( u'O' ) ) np_types = ( np . bool_ , np . object_ , np . number , np . character , np . void ) uniq_types = set ( ( tuple ( ( issubclass ( dtype ( arr ) . type , np_type ) for np_type in np_types ) ) for arr in arrs ) ) if ( len ( uniq_types ) > 1 ) : incompat_types = [ dtype ( arr ) . name for arr in arrs ] tme = MergeConflictError ( u'Arrays have incompatible types {0}' . format ( incompat_types ) ) tme . _incompat_types = incompat_types raise tme arrs = [ np . empty ( 1 , dtype = dtype ( arr ) ) for arr in arrs ] for ( i , arr ) in enumerate ( arrs ) : if ( arr . dtype . kind in ( u'S' , u'U' ) ) : arrs [ i ] = [ ( ( u'0' if ( arr . dtype . kind == u'U' ) else '0' ) * arr . itemsize ) ] arr_common = np . array ( [ arr [ 0 ] for arr in arrs ] ) return arr_common . dtype . str
use numpy to find the common dtype for a list of structured ndarray columns .