def dummy_1d(x, varname=None):
 if (varname is None):
  labels = [('level_%d' % i) for i in range((x.max() + 1))]
  return ((x[:, None] == np.arange((x.max() + 1))).astype(int), labels)
 else:
  grouplabels = np.unique(x)
  labels = [(varname + ('_%s' % str(i))) for i in grouplabels]
  return ((x[:, None] == grouplabels).astype(int), labels)

def dummy_1d ( x , varname = None ) : if ( varname is None ) : labels = [ ( 'level_%d' % i ) for i in range ( ( x . max ( ) + 1 ) ) ] return ( ( x [ : , None ] == np . arange ( ( x . max ( ) + 1 ) ) ) . astype ( int ) , labels ) else : grouplabels = np . unique ( x ) labels = [ ( varname + ( '_%s' % str ( i ) ) ) for i in grouplabels ] return ( ( x [ : , None ] == grouplabels ) . astype ( int ) , labels )
dummy variable for id integer groups paramters x : ndarray .