title: Faster way to assign new values in pandas dataframe
body: <p>I was wondering if there is faster way to assign new values to cells in a pandas dataframe conditional on the value of another cell.  For example, take this df:</p>
  
  <pre><code>df = pd.DataFrame({'rank':[1, 1, 1, 1, 2, 2, 2, 2], 'condition':[.01, .01, .01, .01, .01, .01, .01, .01]})
  </code></pre>
  
  <p>The following code works:</p>
  
  <pre><code>def changerank(row):
      if (row['condition'] == 0) &amp; (row['rank'] &gt; 1):
          row['rank'] = 1
      return row
  
  df = df.apply(changerank, axis=1)
  </code></pre>
  
  <p>But it is rather slow on my real dataframe containing millions of rows.  I feel like there may be another way to change the values of 'rank' depending on values of row.  </p>
  
  <p>Thanks for any thoughts!</p>