title: what is this 'sequence of arrays' created by numpy's np.stack function in Python?
body: <p>I'm reading the <a href="https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.stack.html" rel="nofollow noreferrer">documentation</a> on np.stack:</p>
  <blockquote>
  <blockquote>
  <p>Join a sequence of arrays along a new axis.<br />
  output: ndarray</p>
  </blockquote>
  </blockquote>
  <p>So <code>np.stack</code> is going to take, say, 2 numpy array and return what? It will return a new array, which contains a, um, sequence of arrays?</p>
  <p>I can't visualize what an array consisting of a sequence of arrays is, so how about I run a little experiment:</p>
  <pre><code>import numpy as np
  from random import randint
  
  arrays = [2.5 * np.random.randn(1,2)+ 3 for _ in range(1,3)] 
  arrays = [a.astype(int) for a in arrays]
  arrays
  </code></pre>
  <p>This gives me:</p>
  <pre><code>[array([[1, 2]]), array([[2, 3]])]
  </code></pre>
  <p>Then,</p>
  <p><code>np.stack(arrays, axis=0)</code></p>
  <p>gives</p>
  <pre><code>array([[[1, 2]],
      
  [[2, 3]]])
  </code></pre>
  <p>Pretending for a second that the printout is not basically unreadable (10 square brackets, really?), I see what appears to be 2 arrays, in an array, in a ordered sequence. I guess the documentation is correct, but I still have no mental visualization of what this object looks like.</p>
  <p>Maybe I should look at the dimensions:</p>
  <pre><code>np.stack(arrays, axis=0).shape
  </code></pre>
  <p>gives</p>
  <pre><code>(2, 1, 2)
  </code></pre>
  <p>So we have two rows, one column, and two layers of this? Isn't that one array?</p>
  <p>My questions are:</p>
  <ul>
  <li>What exactly is a 'sequence of arrays' and how does an array possess a notion of order, as does a sequence by definition?</li>
  <li>Why would anyone ever want a 'sequence of arrays' anyway, whatever that is, as opposed to concatenating multiple arrays into one (as the <code>.shape</code> implies this really is anyways)?</li>
  <li>Why did they call this function &quot;stack&quot; and how does the colloquial use of this word attempt to be helpful?</li>
  </ul>
  <p>Thanks.</p>
  <p><strong>EDIT</strong> too many good answers...having trouble selecting one for the checkmark...</p>