def combine_map_label_cols(combinecolorby, mapping):
 combinedmapdata = array(([''] * len(mapping)), dtype='a100')
 title = []
 match = False
 for p in range(len(combinecolorby)):
  for i in range(len(mapping[0])):
   if (str(combinecolorby[p]) == str(mapping[0][i])):
    match = True
    for q in range(len(mapping)):
     combinedmapdata[q] = (combinedmapdata[q] + mapping[q][i])
    break
   else:
    match = False
  if (not match):
   raise ValueError('One of the columns you tried to combine does not exist!')
  title.append(combinecolorby[p])
 combinedmapdata[0] = '&&'.join(title)
 for i in range(len(combinedmapdata)):
  mapping[i].append(combinedmapdata[i])
 return mapping

def combine_map_label_cols ( combinecolorby , mapping ) : combinedmapdata = array ( ( [ '' ] * len ( mapping ) ) , dtype = 'a100' ) title = [ ] match = False for p in range ( len ( combinecolorby ) ) : for i in range ( len ( mapping [ 0 ] ) ) : if ( str ( combinecolorby [ p ] ) == str ( mapping [ 0 ] [ i ] ) ) : match = True for q in range ( len ( mapping ) ) : combinedmapdata [ q ] = ( combinedmapdata [ q ] + mapping [ q ] [ i ] ) break else : match = False if ( not match ) : raise ValueError ( 'One of the columns you tried to combine does not exist!' ) title . append ( combinecolorby [ p ] ) combinedmapdata [ 0 ] = '&&' . join ( title ) for i in range ( len ( combinedmapdata ) ) : mapping [ i ] . append ( combinedmapdata [ i ] ) return mapping
merge two or more mapping columns into one column .