title: Conditional transformation of column in pandas Dataframe
body: <p>I would like to create a new column in my dataframe that is the difference between two variables IF a 3rd column in that row satisfies a certain condition.</p>
  
  <p>A min example looks like this:</p>
  
  <pre><code> dict1 = [{'var0': 0, 'var1': 1, 'var2': 2},
   {'var0': 0, 'var1': 2, 'var2': 4},
  {'var0': 1, 'var1': 5, 'var2': 8},
  {'var0': 1, 'var1': 15, 'var2': 12},]
  df = pd.DataFrame(dict1, index=['s1', 's2','s3','s4'])
  </code></pre>
  
  <p>In particular I want the difference between var0 and var1 (var0-var1), for all rows where var 2 is larger than 3, else I want the difference between var0 and var2 (var0-var2)</p>
  
  <p>My target output would be:</p>
  
  <pre><code>     var0  var1  var2 var3
   s1     0     1     2  -2
   s2     0     2     4  -2
   s3     1     5     8  -4
   s4     1    15    12  -14
  </code></pre>