title: calculate mean across 3 dimensional array of different length
body: <p>I have a 3 dimensional array with dimensions n * d * m. However, ni can vary. It looks something like this</p>
  
  <pre><code>[[[1,1,3],  [[3,2,1],  [[4,3,2],  
    [3,4,2]],  [3,4,2],   [5,2,3]]]
               [4,5,3]],
  </code></pre>
  
  <p>I need to calculate the mean across all data points. I was using the <code>scipy.stats.mean</code> function and but threw error about mismatching dimensions. Therefore, I was thinking about padding the array to the largest ni so that it has uniform dimensions something like this</p>
  
  <pre><code>[[[  1,  1,  3],  [[3,2,1],  [[  4,  3,  2],  
    [  3,  4,  2],   [3,4,2],   [  5,  2,  3],
    [NaN,NaN,NaN]],  [4,5,3]],  [NaN,NaN,NaN]]] 
  </code></pre>
  
  <p>but I don't know if this is the best solution or how I could calculate the mean with NaN. </p>
  
  <p>Any suggestions?</p>