title: Use variable in for loop as dataframe column name
body: <p>I am attempting to use a for loop iterate through a list of column names and on each iteration create a new column based on a string prefix and the original column name (stored in the list). the problem is that the dataframe thinks the variable is a series in the frame when</p>
  
  <pre><code>cols_to_transform = ['Price','Km_From_CBD','Local_Median_Price', 'AreaSize']
  
  for x in cols_to_transform:
      df.x #This is where the problem
      df[x] = df[x&gt;1]
      newcolname = ('T1_Pre_'+ x)
      df.newcolname = df.x + 1 #and same problem here 
  </code></pre>
  
  <p>(DataFrame' object has no attribute 'x')</p>
  
  <p>(DataFrame' object has no attribute 'newcolname' )</p>
  
  <p>Ideally I would have a "global variable" or parameter that overrides the expected pandas object and takes the contents of the variable as a column name rather than the variable itself.</p>
  
  <p>I cannot use pandas apply as in addition to creating the columns I need to create a series of subplots showing the change in transformation.</p>
  
  <p>I know I can cast the whole line of code to string and then use exec, but I'm getting really over doing this as it feels like a cheap work around.</p>
  
  <p>Thanks in Advance!
  Also it's my first question, go easy on me :)</p>