Inserting one item on a matrix
<p>How do I insert a single element into an array on numpy.  I know how to insert an entire column or row using the insert and axis parameter.  But how do I insert/expand by one.</p>

<p>For example, say I have an array:</p>

<pre><code>1 1 1
1 1 1
1 1 1
</code></pre>

<p>How do I insert 0 (on the same row), say on (1, 1) location, say:</p>

<pre><code>1 1 1
1 0 1 1
1 1 1
</code></pre>

<p>is this doable?  If so, then how do you do the opposite (on the same column), say:</p>

<pre><code>1 1 1
1 0 1
1 1 1
  1
</code></pre>

<p>I think you should use <code>append()</code> of regular Python arrays (not numpy)
Here is a short example</p>

<pre><code>A = [[1,1,1],
     [1,1,1],
     [1,1,1]]
A[1].append(1)
</code></pre>

<p>The result is</p>

<pre><code>[[1, 1, 1], 
 [1, 1, 1, 1], 
 [1, 1, 1]]   # like in your example
</code></pre>

<p>Column extension with one element is impossible, because values are stored by rows. Thechnically you can do something like this <code>A.append([None,1,None])</code>, but this is bad practice.</p>

python numpy