title: Changing certain values in multiple columns of a pandas DataFrame at once
body: <p>Suppose I have the following DataFrame:</p>
  
  <pre><code>In [1]: df
  Out[1]:
    apple banana cherry
  0     0      3   good
  1     1      4    bad
  2     2      5   good
  </code></pre>
  
  <p>This works as expected:</p>
  
  <pre><code>In [2]: df['apple'][df.cherry == 'bad'] = np.nan
  In [3]: df
  Out[3]:
    apple banana cherry
  0     0      3   good
  1   NaN      4    bad
  2     2      5   good
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>In [2]: df[['apple', 'banana']][df.cherry == 'bad'] = np.nan
  In [3]: df
  Out[3]:
    apple banana cherry
  0     0      3   good
  1     1      4    bad
  2     2      5   good
  </code></pre>
  
  <p>Why?  How can I achieve the conversion of both the 'apple' and 'banana' values without having to write out two lines, as in</p>
  
  <pre><code>In [2]: df['apple'][df.cherry == 'bad'] = np.nan
  In [3]: df['banana'][df.cherry == 'bad'] = np.nan
  </code></pre>