title: Using list of strings to manipulate pandas columns
body: <p>I have a very long list of strings. These strings are those columns I would like to keep from a dataframe. However, there are a couple of strings in this list that don't match a column header, instead it matches an operation between two or more column headers I would like to performs. </p>
  
  <p>Example: </p>
  
  <pre><code>   df =  @A @B @C @D @E @F
           1   2  3  4  5  6
           9   8  7  6  5  4
           1   3  5  7  9  11
  
  list = ["@A", "@C", "@D / @F"]
  </code></pre>
  
  <p>I would like this to output:</p>
  
  <pre><code>@A @C @D/@F
  1   3  0.667
  9   7  1.5
  1   5  0.63
  </code></pre>
  
  <p>However, I can't for the life of me figure out what to do. 
  To make things a bit more complicated, sometimes in my list you might see a simple division like in my example, sometimes you might see something more complicated like <code>"(C + D) / (A + F)"</code>. How would I do this??</p>
  
  <p>I honestly can't figure out where to start. I thought I could just do something like df[list] and pandas would just "know" what to do, but I think I might be asking a bit too much!</p>
  
  <p>Any help would be appreciated! Thanks.</p>
  
  <p>Edit: 
  After trying to use the eval() method, I've bumped into another issue. I didn't though this could be a problem, but most of my strings begin with the character "@" which throws up an error when passed into the eval function. I'll do some googling on how to work around this, but any additional help is also welcome.</p>
  
  <p>Edit 2: </p>
  
  <p>I figured out a work around for the @ issue. I simply used the replace() method. </p>
  
  <pre><code>lst = [word.replace("@", "") for word in lst]
  </code></pre>
  
  <p>Then, I do the same this for all of my columns as well.</p>