title: Replace values in column based on values in two other columns using pandas
body: <p>I tried to find a solution for my problem, but came up short. Please let me know if it exists elsewhere.</p>
  
  <p>I have a dataframe with 4 columns, like this:</p>
  
  <pre><code>'A'    'B'    'C'      'D'   
  
  cheese  5     grapes    7  
  grapes  7     cheese    8  
  steak   1     eggs      21  
  eggs    2     steak     1
  </code></pre>
  
  <p>The entries in 'C' and 'D' must match the values in 'A' and 'B', but not by row; for example, if "cheese" has "5" in 'B', "cheese" cannot have "8" in 'D'.  In the case of a mismatch, 'C' and 'D' values must be corrected to a default. In this case, "cheese" should should be corrected so that C:default and D:0. Same with eggs, and grapes.  Steak is fine, though.</p>
  
  <p>So the output should look like this:</p>
  
  <pre><code>'A'    'B'  'C'     'D'
  cheese  5    grapes  7 
  grapes  7    default 0  
  steak   1    default 0   
  eggs    2    steak   1
  </code></pre>
  
  <p>I tried to convert 'A' and 'B' to lists with unique values, and then tried to replace 'C' and 'D' values based on the list. I tried all of the conditional df.replace() tricks I could find on stackoverflow, but came up with nothing. </p>
  
  <p>Thank you in advance for any help you provide.</p>