title: When using a pandas dataframe, how do I add column if does not exist?
body: <p>I'm new to using pandas and am writing a script where I read in a dataframe and then do some computation on some of the columns.</p>
  <p>Sometimes I will have the column called &quot;Met&quot;:</p>
  <pre class="lang-py prettyprint-override"><code>df = pd.read_csv(File, 
    sep='\t', 
    compression='gzip', 
    header=0, 
    names=[&quot;Chrom&quot;, &quot;Site&quot;, &quot;coverage&quot;, &quot;Met&quot;]
  )
  </code></pre>
  <p>Other times I will have:</p>
  <pre class="lang-py prettyprint-override"><code>df = pd.read_csv(File, 
    sep='\t', 
    compression='gzip', 
    header=0, 
    names=[&quot;Chrom&quot;, &quot;Site&quot;, &quot;coverage&quot;, &quot;freqC&quot;]
  )
  </code></pre>
  <p>I need to do some computation with the &quot;Met&quot; column so if it isn't present I will need to calculate it using:</p>
  <pre class="lang-py prettyprint-override"><code>df['Met'] = df['freqC'] * df['coverage'] 
  </code></pre>
  <p>is there a way to check if the &quot;Met&quot; column is present in the dataframe, and if not add it?</p>