Merging numpy array elements using join() in python
Question: Want to convert the following numpy array a

    
    
        a =  [
        array([['x', 'y', 'k'], ['d', '2', 'z'], ['a', '15', 'r']], dtype='|S2'), 
        array([['p', '49'], ['l', 'n']], dtype='|S2'), 
        array([['5', 'y'], ['33', 'u'], ['v', 'z']], dtype='|S2'), 
        array([['f', 'i'], ['c', 'm'], ['u', '98']] dtype='|S2')
        ]
    

into output b

    
    
      b =  x!y.d!2.a!15 * x!k.d!z.a!r , p!49.l!n , 5!y.33!u.v!z , f!i.c!m.u!98
    

Consider each sub-array like this

    
    
       #x  #y  #k
       #d  #2  #z
       #a  #15 #r 
    

Then merge 0 and 1 columns with '!' and each row with '.' Then merge 0 and 2
column. And so on. Here **0,1** and **0,2** columns are merged using '*' And
',' is used to merge the sub-arrays

Just merging the strings using `'!' '.' '*' ','`

I tried the following code. Couldnt get the result though

    
    
    temp = []
    for c in a:
        temp = a[0:]
        b =  " * ".join(".".join(var1+"!"+var2 for var1,var2 in zip(temp,a) for row in a)
        print b
    print " , "
    


Answer: How I understand, your solution maybe like this:

    
    
    import numpy as np
    a =  [
      np.array([['x', 'y', 'k'], ['d', '2', 'z'], ['a', '15', 'r']], dtype='|S2'),
      np.array([['p', '49'], ['l', 'n']], dtype='|S2'),
      np.array([['5', 'y'], ['33', 'u'], ['v', 'z']], dtype='|S2'),
      np.array([['f', 'i'], ['c', 'm'], ['u', '98']], dtype='|S2')
      ]
    
    aa = []
    for k in a:
      bb = []
      for i in range(len(k[0]) - 1):
        cc = []
        for j in range(len(k)):
          cc.append('!'.join([k[j][0], k[j][i + 1]]))
        bb.append('.'.join(cc))
      aa.append(' * '.join(bb))
    b = ' , '.join(aa)
    
    print b
    

If it's wrong, please, clarify your algorithm.

