insert element in the start of the numpy array
<p>I have array </p>

<pre><code>x=[ 0.30153836  0.30376881  0.29115761  0.29074261  0.28676876 ]
</code></pre>

<p>I want to insert -1 to the start of the array to be like </p>

<pre><code>  x= [-1 0.30153836  0.30376881  0.29115761  0.29074261  0.28676876]
</code></pre>

<p>I tried :</p>

<pre><code>np.insert(x,0,-1,axis=0)
</code></pre>

<p>but it didn't do any change, any idea how to do that ?</p>

<p>You can do the insert by ommiting the axis param:</p>

<pre><code>x = np.array([0,0,0,0])
x = np.insert(x, 0, -1)
x
</code></pre>

<p>That will give:</p>

<pre><code>array([-1,  0,  0,  0,  0])
</code></pre>

python arrays numpy