title: How to convert values in table using petl
body: <p>I am having a weird issue with converting multiple values in a table. </p>
  
  <p>I have a <code>table</code> of data like so:</p>
  
  <pre><code>+-------------+--------------+-------------+
  | id          | name         | category_id |
  +=============+==============+=============+
  |         1   |       Horse  | 5           |
  +-------------+--------------+-------------+
  |         2   |        Cow   | 5           |
  +-------------+--------------+-------------+
  |         3   |        Pig   | 2           |
  +-------------+--------------+-------------+
  |         4   |     Chicken  | 3           |
  +-------------+--------------+-------------+
  </code></pre>
  
  <p>I am then finding by <code>category_id</code> like so:</p>
  
  <pre><code># find the item category id
  items_cat_id = etl.values(table, 'category_id')
  </code></pre>
  
  <p>I then loop over the data like so so I can convert the category_id from the above to the target category id:</p>
  
  <pre><code>    for item in items_cat_id:
          """ 
          fetch target mongo collection. 
          source_name is the category name to look up in the target, 
          if we get a match convert the table category_id value to 
          the mongo id.
          """
          target_category_id = target_db.collection.find_one({ 'name': source_name })
  
          converted_table = etl.convert(table, 'category_id', 
              lambda _: target_category_id.get('_id'), 
              where=lambda x: x.category_id == item)
  </code></pre>
  
  <p>I seem to be only getting this:</p>
  
  <pre><code>+-------------+--------------+-----------------------------+
  | id          | name         | category_id                 |
  +=============+==============+=============================+  
  |         1   |       Horse  | 5                           |
  +-------------+--------------+-----------------------------+
  |         2   |        Cow   | 5                           |
  +-------------+--------------+-----------------------------+
  |         3   |        Pig   | 2                           |
  +-------------+--------------+-----------------------------+
  |         4   |     Chicken  | QnicP3f4njL54HRqu           |
  +-------------+--------------+-----------------------------+
  </code></pre>
  
  <p>when it should be</p>
  
  <pre><code>+-------------+--------------+-----------------------------+
  | id          | name         | category_id                 |
  +=============+==============+=============================+
  |         1   |       Horse  | 5                           |
  +-------------+--------------+-----------------------------+
  |         2   |        Cow   | 5                           |
  +-------------+--------------+-----------------------------+
  |         3   |        Pig   | yrDku5Yqkc2MKZZkD           |
  +-------------+--------------+-----------------------------+
  |         4   |     Chicken  | QnicP3f4njL54HRqu           |
  +-------------+--------------+-----------------------------+
  </code></pre>
  
  <p>Any suggestions?</p>