title: how to compute a new column based on the values of other columns in pandas - python
body: <p>Let's say my data frame contains these data:</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame({'a':['l1','l2','l1','l2','l1','l2'],
                         'b':['1','2','2','1','2','2']})
  &gt;&gt;&gt; df
      a       b
  0  l1       1
  1  l2       2
  2  l1       2
  3  l2       1
  4  l1       2
  5  l2       2
  </code></pre>
  
  <p><code>l1</code> should correspond to <code>1</code> whereas <code>l2</code> should correspond to <code>2</code>. 
  I'd like to create a new column '<code>c</code>' such that, for each row, <code>c = 1</code> if <code>a = l1</code> and <code>b = 1</code> (or <code>a = l2</code> and <code>b = 2</code>). If <code>a = l1</code> and <code>b = 2</code> (or <code>a = l2</code> and <code>b = 1</code>) then <code>c = 0</code>.</p>
  
  <p>The resulting data frame should look like this: </p>
  
  <pre><code>  a         b   c
  0  l1       1   1
  1  l2       2   1
  2  l1       2   0
  3  l2       1   0
  4  l1       2   0
  5  l2       2   1
  </code></pre>
  
  <p>My data frame is very large so I'm really looking for the most efficient way to do this using pandas.</p>