title: Optimizing dataframe manipulation: new column based on conditional logic and multiple columns
body: <p>Currently, this works: </p>
  
  <pre><code>df['new'] = df.apply( \
         lambda x: address[int(x['c1'][:5], 2)]+'_'+str(int(x['c1'][6:11], 2)) \
         if x['c1'][5] == '1' \
         else address[int(x['c2'][:5], 2)]+'_'+str(int(x['c2'][6:11], 2)), axis=1) `
  </code></pre>
  
  <p><code>address</code> is a dictionary.</p>
  
  <p>But it's <strong>really slow</strong>. Specifically, <code>apply</code>ing to the whole dataframe is considerably slower than <code>apply</code>ing to a selected column. However, the new column is based on multiple columns and I'm not sure how to implement that.</p>
  
  <p>Additionally, is there a way to vectorize these types of logical/conditional statements? </p>
  
  <p>sample dataframe:
  <code>
  &lt;bound method DataFrame.head of                      c1                c2
  0      0000100111000111  0010110011000111
  1      0001000111000111  0010110011000111
  2      0101010001001010  0000000000000000
  3      0101010010001110  0000000000000000
  4      0101010011101010  0000000000000000
  5      0111111100000100  0000000000000000
  6      0111110010010110  0000000000000000
  7      1000000001001100  0000000000000000
  8      1110011110001000  0000000000000000
  9      0000100001010000  0000000000000000
  10     0001000001001010  0000000000000000
  11     0101101100100100  0000000000000000
  12     1110001100100100  0000000000000000
  13     0010100101101001  0101010101101001
  14     0000100101100000  0000000000000000
  15     0000100110100000  0000000000000000
  16     0001000101101011  0000000000000000
  17     1001110000100001  0000000000000000
  18     0111111000100000  0000000000000000
  19     1000000100010110  0000000000000000
  20     1110001111000010  0000000000000000
  21     1011010001000010  0000000000000000
  22     0110010001001111  0000000000000000
  23     0111110000110101  0000000000000000
  24     0111110001001100  0000000000000000
  25     1000000000111101  0000000000000000
  26     0000110001100010  0000000000000000
  27     0001010001100010  0000000000000000
  28     1100100100100101  1001011000000101
  29     0101000010101010  0111110001001010
  ...                 ...               ...
  95714  0101111100011000  0000000000000000
  95715  0010101011001011  0000000000000000
  95716  0010100111100110  0101010110100110
  95717  0010101000100100  0101011011100100
  95718  0101000110000101  0000000000000000</code></p>