title: Apply lambda on a column in pandas
body: <p>I have the below data frame</p>
  
  <pre><code>ipdb&gt; csv_data
    country_edited  sale_edited  date_edited  transformation_edited
  0          India       403171     21091956                      1
  1         Bhutan       394096     21091956                      2
  2          Nepal       361372     21091956                      3
  3         madhya       355883     21091956                      4
  4          sudan       262949     21091956                      5
  </code></pre>
  
  <p>and below is my code</p>
  
  <pre><code>transfactor_count = 5.6
  csv_data["transformation_edited"] = csv_data["transformation_edited"].apply(lambda x: x * transfactor_count)
  </code></pre>
  
  <p>But the above code  was giving me an error </p>
  
  <pre><code>*** NameError: global name 'transfactor_count' is not defined
  </code></pre>
  
  <p>How to solve this ?</p>
  
  <h2>Actual code</h2>
  
  <pre><code>for foreign_key in data_mapping_record.csvdatabasecolumnmapping_set.all():
      data_type = foreign_key.data_type
      trans_factor = foreign_key.tranformation_factor
      if data_type == "Decimal":
          import ipdb; ipdb.set_trace()
          csv_data[foreign_key.table_column_name] = csv_data[foreign_key.table_column_name].apply(lambda x: x * trans_factor )
      elif data_type in ["Date", "Datetime"]:
          csv_data[foreign_key.table_column_name] = csv_data[foreign_key.table_column_name].apply( lambda d: datetime.strptime(d, dates[date]) )
  </code></pre>