title: How to compute the total number of bills per clients'age?
body: <p>I have two datasets, one the client with their respective bills,with the following elements: "number of bill", "date", "client", import", and the other dataset are the clients grouped by age.</p>
  
  <p>****An example:**** </p>
  
  <pre><code>1st Dataset             
  u'F1,01/01/2013,C1,11'
  
  2nd Dataset 
  u'C1,20' 
  </code></pre>
  
  <p>I have parsed the two data set to select the data of importance to my subject. Here is the code</p>
  
  <pre><code>def parseClients(clients):
      fields=clients.split(",")
      return (fields[0], fields[1])
  
  def parseBill(bill):
      fields=bill.split(",")
      return (fields[2], bill)
  
  new_bills=bills.map(parseBill)
  new_clients=clients.map(parseClients)
  
  Age_Bills=new_bills.join(new_clients)
  </code></pre>
  
  <p>A sample as following:</p>
  
  <pre><code>Age_Bills.take(10):
  (u'C856', (u'F2982,06/01/2013,C856,88', u'81'))
  (u'C856', (u'F11953,22/01/2013,C856,87', u'81'))
  (u'C856', (u'F12893,24/01/2013,C856,10', u'81'))
  (u'C856', (u'F12913,24/01/2013,C856,41', u'81'))
  (u'C856', (u'F17883,02/02/2013,C856,45', u'81'))
  (u'C856', (u'F17895,02/02/2013,C856,75', u'81'))
  (u'C856', (u'F18867,04/02/2013,C856,105', u'81'))
  (u'C856', (u'F21864,09/02/2013,C856,26', u'81'))
  (u'C856', (u'F30889,26/02/2013,C856,154', u'81'))
  (u'C856', (u'F49990,02/04/2013,C856,90', u'81'))
  </code></pre>
  
  <p>Now I'd like to count the number of bills
   per age, but I don't know how to continue. I have thought about using KeyReduce or flatmap. I would  be grateful if you could help me.</p>
  
  <p>Thanks,</p>