title: Reduce a key-value pair into a key-list pair with Apache Spark
body: <p>I am writing a Spark application and want to combine a set of Key-Value pairs <code>(K, V1), (K, V2), ..., (K, Vn)</code> into one Key-Multivalue pair <code>(K, [V1, V2, ..., Vn])</code>. I feel like I should be able to do this using the <code>reduceByKey</code> function with something of the flavor:</p>
  
  <pre><code>My_KMV = My_KV.reduce(lambda a, b: a.append([b]))
  </code></pre>
  
  <p>The error that I get when this occurs is:</p>
  
  <blockquote>
    <p>'NoneType' object has no attribue 'append'.</p>
  </blockquote>
  
  <p>My keys are integers and values V1,...,Vn are tuples.  My goal is to create a single pair with the key and a list of the values (tuples).</p>