擅长:python、mysql、java
<p>如果您查看位于<a href="https://www.safaribooksonline.com/library/view/learning-spark/9781449359034/ch04.html" rel="nofollow">https://www.safaribooksonline.com/library/view/learning-spark/9781449359034/ch04.html</a>的cogroup文档,可以看到它返回RDD[(K,(Iterable[V],Iterable[W])],其中Iterable[V]和Iterable[W]包含两个独立RDD的值。您必须对它们进行迭代,或者通过调用list(…)将它们转换成一个列表。在</p>
<p>我假设这样的代码可以工作(注:代码未测试):</p>
<pre><code>users_prods_joined.map(lambda (k, mapped): "{0} {1}".format(k,str(list(mapped[0]) + list(mapped[1]))))
</code></pre>