title: How to create a 4 dimensional numpy array from a 3 dimensional numpy array filling with zeros?
body: <h1>The problem</h1>
  <p>Create a higher dimensional NumPy array with zeros on the new dimensions</p>
  <h2>Details</h2>
  <p>Analyzing the last dimension, the result is similar to this:</p>
  <p>(not an actual code, just a didactic example)</p>
  <pre><code>a.shape = (100,2,10) 
  a[0,0,0]=1
  a[0,0,1]=2  
  ...
  a[0,0,9]=10
  
  b.shape = (100,2,10,10)
  b[0,0,0,:]=[0,0,0,0,0,0,0,0,0,1]
  b[0,0,1,:]=[0,0,0,0,0,0,0,0,2,1] 
  b[0,0,2,:]=[0,0,0,0,0,0,0,3,2,1]
  ...
  b[0,0,2,:]=[10,9,8,7,6,5,4,3,2,1] 
      
  a -&gt; b 
  </code></pre>
  <p>The objective is to transform from <code>a</code> into <code>b</code>. The problem is that is not only filled with zeros but has a sequential composition with the original array.</p>
  <h2>Simpler problem for better understanding</h2>
  <p>Another way to visualize is using lower-dimensional arrays:</p>
  <p>We have this:</p>
  <pre><code>a = [1,2]
  </code></pre>
  <p>And I want this:</p>
  <pre><code>b = [[0,1],[2,1]]
  </code></pre>
  <p>Using NumPy array and avoiding long for loops.</p>
  <h2>2d to 3d case</h2>
  <p>We have this:</p>
  <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]]
  </code></pre>
  <p>And I want this:</p>
  <pre><code>b[0] = [[0,0,1],[0,2,1],[3,2,1]]
  b[1] = [[0,0,4],[0,5,4],[6,5,4]]
  b[2] = [[0,0,7],[0,8,7],[9,8,7]]
  </code></pre>
  <p>I feel that for the 4-dimensional problem only one for loop with 10 iterations is enough.</p>