title: Create Formula Based on Dynamically Changing Columns to Set Values in Pandas Dataframe Column
body: <p>I am looking to create a column in a pandas dataframe that is the function of a variable/dynamic list of column names.</p>
  
  <p>Typical column creation would be:</p>
  
  <pre><code>df['new']=(df['one']*x)+(df['two']*y)+(df['3']*z)
  </code></pre>
  
  <p>where x,y,z are variables from another df.</p>
  
  <pre><code>x 1.1
  y 1.2
  z 1.3
  a 1.4
  b 1.5
  c 1.6
  </code></pre>
  
  <p>I want to create a column which would be a function of a variable list of columns.  </p>
  
  <p>So for instance if:</p>
  
  <pre><code>cols=['one','two']
  </code></pre>
  
  <p>then the formula would be created as:</p>
  
  <pre><code>df['new']=(df['one']*x)+(df['two']*y)
  </code></pre>
  
  <p>But if cols changes to:</p>
  
  <pre><code>cols=['one','two','three','four']
  </code></pre>
  
  <p>then the formula would change to:</p>
  
  <pre><code>df['new']=(df['one']*x)+(df['two']*y)+(df['3']*z)+(df['four']*a)
  </code></pre>
  
  <p>I know I must be missing something easy here.  </p>