Numpy array slicing using colons
<p>I am trying to learn numpy array slicing.</p>

<p>But this is a syntax i cannot seem to understand.</p>

<p>What does </p>

<p><code>a[:1]</code> do. </p>

<p>I ran it in python.</p>

<pre><code>a = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])
a = a.reshape(2,2,2,2)
a[:1]
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>array([[[ 5,  6],
        [ 7,  8]],

       [[13, 14],
        [15, 16]]])
</code></pre>

<p>Can someone explain to me the slicing and how it works. The documentation doesn't seem to answer this question.</p>

<p>Another question would be would there be a way to generate the a array using something like </p>

<p><code>np.array(1:16)</code> or something like in python where</p>

<pre><code>x = [x for x in range(16)]
</code></pre>