PySpark reduceByKey with multiple values
<p>So while I have the identical title as this question: <a href="http://stackoverflow.com/questions/30831530/pyspark-reducebykey-on-multiple-values">PySpark reduceByKey on multiple values</a></p>

<p>I cannot get the answer to work for what I want to do.</p>

<pre><code>A = sc.parallelize([("a", (1,0)), ("b", (4,2)),("a", (11,2)), ("b", (4,10))])
A.reduceByKey(lambda x, y: x[0]+y[0],x[1]+y[1]).collect()
</code></pre>

<p>Gives me the error:</p>

<pre><code>name 'x' is not defined
</code></pre>

<p>Whats going on here?    </p>

<p>I found the problem.  Some parenthesis:</p>

<pre><code>A.reduceByKey(lambda x, y: (x[0]+y[0] ,x[1]+y[1])).collect()
</code></pre>

python apache-spark pyspark