title: Need help on Pandas Dataframe creation by passing a dynamic argument list to a function
body: <p>I have a table T1 as shown below (stored as dataframe df3 with columns col1, col2 and col3)</p>
  
  <p>df2 has columns 'l', 'm', 'n'...</p>
  
  <p>df1 has columns 'a', 'b', 'c'</p>
  
  <pre>col1       col2       col3
  
  x            add       {'a':'df1','l':'df2','n':'df2'}
  
  y            sub        {'b':'df1','m':'df2'} 
  
  z            sqrt       {'c': 'df1'} 
  </pre>
  
  <p>Value <strong>x</strong> in col1 is to be calculated using operation <strong>add</strong> in col2 using parameters <em>key:value</em> pairs in col3 (<strong>a</strong> in <strong>df1</strong>, <strong>l</strong> in <strong>df2</strong>, ...)</p>
  
  <p>Likewise, value <strong>y</strong> in col1 is to be calculated using operation <strong>sub</strong> in col2 using parameters in col3 (<strong>b</strong> in <strong>df1</strong>, <strong>m</strong> in <strong>df2</strong>); the number of <em>k:v</em> pairs in Col3 could be more OR less depending upon the operation/function defined in col 2, for <strong>sqrt</strong> for instance, there is only 1 pair</p>
  
  <p>I want to get the output in form a dataframe df4 as mentioned below</p>
  
  <pre>
   x                           y                      z
  
  df1['a']+df2['l']+df2['n']   df1['b'] - df2['m']    df1['c]
  
  
  </pre>
  
  <p>I am trying achieve this by building a function as mentioned below but I am not sure how shall I build and pass a dynamic arguments list to this function where number of arguments to be passed depends upon the number of <em>k:v</em> pairs assigned in col3? In my case for <strong>add</strong> I have 3 and for <strong>sub</strong> I have 2 and for <strong>sqrt</strong>, I have only 1
  <pre></p>
  
  <p>for ix,row in df3.iterrows():</p>
  
  <code>          call_operation = row['col2']
  
            target_value = row['col1']
  
            #df4[target_value] = getattr(module,call_operation)(df2[b],df1[a])
  
            df4[target_value] = getattr(module,call_operation)( &lt;dynamic argument list form col3&gt; )
  </code></pre>