title: Join strings along axis
body: <p>Suppose I have a numpy array of strings, like this:</p>
  
  <pre><code>import numpy as np
  print('numpy version:', np.__version__)
  
  a = np.arange(25).reshape(5, 5)
  stra = a.astype(np.dtype(str))
  
  print(stra)
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>numpy version: 1.15.2
  [['0' '1' '2' '3' '4']
   ['5' '6' '7' '8' '9']
   ['10' '11' '12' '13' '14']
   ['15' '16' '17' '18' '19']
   ['20' '21' '22' '23' '24']]
  </code></pre>
  
  <p>I want to work along a given axis, choose some elements, and join those strings.  First I tried this:</p>
  
  <pre><code>print(np.apply_along_axis('|'.join, 1, stra.take([2, 3], 1)))
  </code></pre>
  
  <p>But the longer resulting strings get truncated to match the shortest:</p>
  
  <pre><code>['2|3' '7|8' '12|' '17|' '22|']
  </code></pre>
  
  <p>I can of course write my own loop to get the output I want, but it's somewhat unsatisfying to do this when the one-liner so nearly works.</p>
  
  <pre><code>def join_along_axis(array, indices, axis):        
      if array.ndim == 1:
          return np.array('|'.join(array.take(indices)))
  
      joined = []        
      # Move axis of interest to end and flatten others to make the loop easy.
      work_arr = np.rollaxis(array, axis, -1)
      shape = work_arr.shape
      new_shape = (np.product(work_arr.shape[:-1]), work_arr.shape[-1])
      work_arr = work_arr.reshape(new_shape)
  
      for arr in work_arr:
          joined.append('|'.join(arr.take(indices)))
  
      return np.array(joined).reshape(shape[:-1])
  
  print(join_along_axis(stra, [2, 3], 1))
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>['2|3' '7|8' '12|13' '17|18' '22|23']
  </code></pre>
  
  <p>Is there a slicker way to do this than my <code>join_along_axis</code> function?</p>
  
  <p><strong>Update for clarity:</strong>  I need this to be general enough to work on an array with arbitrary number of dimensions and along any chosen axis.</p>