title: Creating a column whose values depend on other columns and the created columns previous values
body: <p>I have a pandas dataframe with the three columns names A, B, C and want to add a fourth column with the following condition:</p>
  
  <p>Note: prev X = previous entry of the column X</p>
  
  <pre><code>D = IF(A &lt; prev D) and (B &gt; prev D)
  
  THEN A
  
  ELSE prev D
  </code></pre>
  
  <p>Is there a way other than using for loop for accomplishing this using pandas or numpy?</p>