2017-04-05 91 views
0

我有RDD如下,拼接元素

>>> rdd.collect() 
[([u'steve'], [u'new', u'york'], [u'baseball']), ([u'smith'], [u'virginia'], [u'football'])] 

我怎樣才能獲得新的RDD爲,

[([u'steve'], [u'newyork'], [u'baseball']), ([u'smith'], [u'virginia'], [u'football'])] 

我想它映射到新RDD與加入,但它不列入工作

回答

0

我能解決這個問題,

>>> rdd2=rdd.map(lambda l: [''.join(x) for x in l]) 
>>> rdd2.map(tuple).collect() 
[([u'steve'], [u'newyork'], [u'baseball']), ([u'smith'], [u'virginia'], [u'football'])]