title: Using logical operators in building a Pandas DataFrame
body: <p>I have two snippets of pandas code which I think should be equivalent, but the second one doesn't do what I expect.</p>
  
  <pre><code># snippet 1
      data = all_data[[((np.isfinite(all_data[self.design_metric][i]) 
                      and all_data['Source'][i] == 2)) 
                      or ((np.isfinite(all_data[self.actual_metric][i]) 
                      and all_data['Source'][i] != 2))
                      for i in range(len(all_data))]]
  
  
  # snippet 2
      data = all_data[(all_data['Source'] == 2 &amp;
                      np.isfinite(all_data[self.design_metric])) |
                      (all_data['Source'] != 2 &amp;
                      np.isfinite(all_data[self.actual_metric]))]
  </code></pre>
  
  <p>Each section (e.g. <code>all_data['Source'] == 2</code> ) does what I expect on its own but it seems that I'm doing something wrong with the logical operators as the final result is coming out with a different result to the list comprehension version.</p>