title: Make new column by turning each row into a dict in a pandas dataframe
body: <p>So I have have created a pandas dataframe from the following csv:</p>
  
  <pre><code>id  age00   education   marital gender  ethnic  industry    income00
  0   51.965         17         0      1       0         5    76110
  1   41.807         12         1      0       0         1    43216
  2   36.331         12         1      0       1         3    52118
  3   56.758          9         1      1       2         2    47770
  </code></pre>
  
  <p>My goal is to create a new column called <strong>future_income</strong> which takes each row and calculates future income using my model.</p>
  
  <p>This is done by the <strong>predictFinalIncome</strong> variable in a class I created below:</p>
  
  <pre><code>class myModel:
    def __init__(self, bias) :
      self.bias = bias # bias is a dictionary with info to set bias on the gender function and the ethnic function
  
  
    def b_gender(self, gender):
      effect = 0
      if (self.bias["gender"]): # if there is gender bias in this model/world (from the constructor) 
        effect = -0.0005 if (gender&lt;1) else 0.0005  # This amount to 1.2% difference annually
      return self.scale * effect
  
    def b_ethnic(self, ethnic):
      effect = 0
      if (self.bias["ethnic"]): # if there is ethnic bias in this model/world (from the constructor) 
        effect = -0.0007 if (ethnic &lt; 1) else -0.0003 if (ethnic &lt; 2) else 0.0005 
      return self.scale * effect
  
  
    # other methods/functions
    def predictGrowthFactor( self, person ): # edited
      factor = 1 + person['education'] + person['marital'] + person['income'] + person['industry']
      return factor
  
    def predictIncome( self, person ): # perdict the new income one MONTH later. (At least on average, each month the income grows.)
      return person['income']*self.predictGrowthFactor( person )
  
    def predictFinalIncome( self, n, person ): 
      n_income = self.predictIncome( person )
      for i in range(n):
         n_income = n_income * i
      return n_income
  
  </code></pre>
  
  <p>n in this case is 120. </p>
  
  <p>So in short. I would like to take each row, throw it into the class function called <strong>predictFinalIncome</strong> and have a new variable on my df called future_income, which is their income in 120 months.</p>
  
  <p>EDIT:</p>
  
  <p>I actually don't need the person class. I accidentally removed my init__ in the class which determines the argument 'bias'. Instead, based off @Cavin Dsouza's code. But this doesnt work.</p>
  
  <p>The code is then read in like: </p>
  
  <pre><code>utopModel = myModel( { "gender": False, "ethnic": False } ) # no bias
  
  
  n =120
  #Utopia
  u = utopModel
  world1['incomeFinal_utop'] = world1.apply(lambda row: u.predictFinalIncome(n, row), axis=1)
  </code></pre>
  
  <p>So the error is this when it goes to the predictFinalIncome:</p>
  
  <pre><code>TypeError: 'str' object cannot be interpreted as an integer
  
  During handling of the above exception, another exception occurred:
  
  KeyError        
  
  KeyError: 'income'
  
  
  </code></pre>