title: How to check if a column exists in Pandas
body: <p>How do I check if a column exists in a Pandas DataFrame <code>df</code>?</p>
  <pre><code>   A   B    C
  0  3  40  100
  1  6  30  200
  </code></pre>
  <p>How would I check that the column <code>&quot;A&quot;</code> exists in the above DataFrame so that I can compute:</p>
  <pre><code>df['sum'] = df['A'] + df['C']
  </code></pre>
  <p>And if <code>&quot;A&quot;</code> doesn't exist:</p>
  <pre><code>df['sum'] = df['B'] + df['C']
  </code></pre>