title: List of dictionaries set comprehension calculation
body: <p>My data structure is a list of dicts. I would like to run a function over the values of certain keys, and then output only a certain number of dictionaries as the result.</p>
  
  <pre><code>from datetime import datetime
  from dateutil.parser import parse
  
  today = '05/17/18'
  adict = [{'taskid':1,'desc':'task1','complexity':5,'dl':'05/28/18'},{'taskid':2,'desc':'task2','complexity':3,'dl':'05/20/18'},
           {'taskid':3,'desc':'task3','complexity':1,'dl':'05/25/18'}]
  
  def conv_tm(t):
      return datetime.strptime(t,'%m/%d/%y')
  
  def days(obj):
      day = conv_tm(today)
      dl = conv_tm(obj)
      dur = (dl-day).days
      if dur &lt;0:
          dur = 1
      return dur
  </code></pre>
  
  <p>I found the easiest way to process the dates for the 'dl' key was to run this dict comprehension:</p>
  
  <pre><code>vals = [days(i['dl']) for i in adict]
  
  #this also worked, but I didn't like it as much
  vals = list(map(lambda x: days(x['dl']), adict))
  </code></pre>
  
  <p>Now, I need to do 2 things: 1) zip this list back up to the 'dl' key, and 2)return or print a (random) set of 2 dicts w/o altering the origianl dict, perhaps like so:</p>
  
  <pre><code>{'taskid':1,'desc':task1,'dl':8,'complexity':5}
  {'taskid':3,'desc':task3,'dl':8,'complexity':1}
  </code></pre>
  
  <p>Cheers</p>