title: Fill an array with nan in numpy
body: <p>I have a numpy vector my_indexes of size <strong>1XN</strong> which contain boolean values of indexing and a 2D array my_array of size <strong>MxK</strong> where K &lt;&lt; N. Actually, the boolean vector correspond to columns that I remove (or keep in the array my_array) and I want to add those columns back filled with zeros (or 'NaNs'). My code for removing the columns:</p>
  
  <pre><code> my_array= np.array(my_array[:, ~np.all(np.isnan(my_array), axis=0)])
   cols = np.all(np.isnan(my_array), axis=0)
   my_array = some_process(my_array)
   # How can I add the removed columns
  </code></pre>
  
  <p>My array if of size <strong>MXN</strong> and then the size is <strong>MXK</strong>. How can I fill the removed columns again with nan or zeros?</p>
  
  <p>An example could be:</p>
  
  <pre><code>0.1 nan 0.3 .04 nan 0.12 0.12
  0.1 nan 0.3 .04 nan 0.12 0.12
  0.1 nan 0.3 .04 nan 0.12 0.12
  </code></pre>
  
  <p>Firstly, I want to remove the nan columns using <code>my_array= np.array(my_array[:, ~np.all(np.isnan(my_array), axis=0)])</code>. </p>
  
  <pre><code>0.1 0.3 .04 0.12 0.12
  0.1 0.3 .04 0.12 0.12
  0.1 0.3 .04 0.12 0.12
  </code></pre>
  
  <p>And the my_indexes vector is:</p>
  
  <pre><code>False True False False True False False
  </code></pre>
  
  <p>Then I want to process the matrix and then have the nan columns back (note that the preprocessing cannot happened with the nan columns). I guess that I need to use the <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.insert.html" rel="nofollow noreferrer">np.insert function</a> however how can I do so using my boolean vector </p>