title: How to drop Pandas dataframe columns based on another boolean array's column values?
body: <p>I am trying to drop the columns of a Pandas Dataframe <strong>based on the value of the columns of a second Boolean array</strong> (that has the same length).</p>
  
  <p>For example suppose the pandas dataframe</p>
  
  <pre><code>[value1, value2, value3]
  </code></pre>
  
  <p>and a boolean array</p>
  
  <pre><code>[True, False, True].
  </code></pre>
  
  <p>The result of the dropping operation on the Pandas dataframe would be</p>
  
  <pre><code>[value1, value3] 
  </code></pre>
  
  <p>Notice that we dropped the second column that has value False on the boolean array. </p>
  
  <p>I guess something like this would work fine:</p>
  
  <pre><code>for i in range(len(boolean_array)):
      if boolean_array[i] == False:
          df = df.drop(df.columns[i], axis=1)
  </code></pre>
  
  <p>but I am pretty sure there is an easier way.</p>