title: Changing an existing column conditional on two other column
body: <p>I have a data set:</p>
  <pre><code>ID    Fv_year   HP_b_year    HP_e_year
  
  1      2010       0            2012
  2       0        2009          2011
  3      2000       0            2008
  4      2001       0             0          
  </code></pre>
  <p>I want generate:</p>
  <pre><code>ID    Fv_year  HP_b_year      HP_e_year
  
  1      2010     2010            2012
  2       0       2009            2011
  3      2000     2000            2008
  4      2001      0               0  
  
  </code></pre>
  <p>In word, when Fv_year &gt;0 , HP_b_year =0 and HP_e_year&gt;0 then I want to make HP_b_year = Fv_year, otherwise keep HP_b_year as it was before. I have used following cod:</p>
  <pre><code>def myfunc(x,y,z):
      if x == 0 and y&gt;0 and z&gt;0:
          return y
      else:
          return x
  
  df['HP_b_year'] = df.apply(lambda x: myfunc(x.HP_b_year, x.Fv_year, x.HP_e_year), axis=1)
  
  </code></pre>
  <p>But its not working</p>