title: How to replace the first dimension of a 3D numpy array with values from a 1D array?
body: <p>I've got a 3D and a 1D numpy array- A sized (3750, 17, 1000) and B sized (3750). I want to replace the values in the 1st dimension of A with the values from array B, so that the resulting array C is still sized (3750, 17, 1000), but the values in the first dimension are different. </p>
  
  <pre><code>&gt;&gt;&gt; A.shape
  (3750, 17, 1000)
  
  &gt;&gt;&gt; B.shape (3750,)
  
  &gt;&gt;&gt; C.shape(3750, 17, 1000)
  </code></pre>
  
  <p>I've tried: </p>
  
  <pre><code>&gt;&gt;&gt; C = np.concatenate((A, np.broadcast_to(np.array(B)[:, None, None],A.shape)), axis = 0)
  </code></pre>
  
  <p>But the output is:</p>
  
  <pre><code>&gt;&gt;&gt; C.shape (7500, 17, 1000)
  </code></pre>
  
  <p>So basically if</p>
  
  <p>A =</p>
  
  <pre><code>
  1 [x, y ... 1000]
  
    [x, y ... 1000]
  
    ...17
  
  2 [x, y ... 1000]
  
    [x, y ... 1000]
  
    ...17
  
  3 [x, y ... 1000]
  
    [x, y ... 1000]
  
    ...17
  .
  .
  .
  3750
  </code></pre>
  
  <p>and B = </p>
  
  <pre><code>22
  43
  11
  .
  .
  n=3750
  </code></pre>
  
  <p>Then C should look like</p>
  
  <pre><code>22 [x, y ... 1000]
     [x, y ... 1000]
      ...17
  
  43 [x, y ... 1000]
     [x, y ... 1000]
      ...17
  
  11 [x, y ... 1000]
     [x, y ... 1000]
      ...17
  .
  .
  .
  n=3750
  </code></pre>