title: Understanding group by MapReduce in spark (python)
body: <p>I am trying a small program where I am considering an employee dataset and trying to calculate sum of salaries distributed in various departments. I have a reproducible example.</p>
  
  <pre><code> emp_list=[(u'ACC', [u'101', u'a', u'ACC', u'1000']),
   (u'SALES', [u'102', u'b', u'SALES', u'2000']),
   (u'IT', [u'103', u'c', u'IT', u'3000']),
   (u'ACC', [u'104', u'd', u'ACC', u'4000']),
   (u'ACC', [u'105', u'e', u'ACC', u'5000']),
   (u'HR', [u'106', u'f', u'HR', u'6000']),
   (u'ACC', [u'107', u'g', u'ACC', u'7000']),
   (u'FIN', [u'108', u'h', u'FIN', u'8000']),
   (u'ACC', [u'109', u'k', u'ACC', u'9000']),
   (u'HR', [u'1010', u'l', u'HR', u'10000']),
   (u'ACC', [u'1011', u'm', u'ACC', u'11000']),
   (u'ACC', [u'1012', u'n', u'ACC', u'12000']),
   (u'FIN', [u'1013', u'o', u'FIN', u'13000']),
   (u'IT', [u'1014', u'p', u'IT', u'14000'])]
  
  emp=sc.parallelize(emp_list)
  
  emp.reduceByKey(lambda x,y : x[3]+y[3]).take(10)
  </code></pre>
  
  <p>Output I am getting is :</p>
  
  <pre><code>[(u'ACC', u'00'),
   (u'HR', u'600010000'),
   (u'FIN', u'800013000'),
   (u'SALES', [u'102', u'b', u'SALES', u'2000']),
   (u'IT', u'300014000')]
  </code></pre>
  
  <p>Can anybody please explain me why I am getting strange values for <code>ACC</code> and <code>SALES</code> departments. I want to see the concatenated salaries for these two as well.</p>