我有一个带有1个键和多个值的键值RDD。如何创建新的RDD以使其中一个值成为键并且键成为值?
Ex现有的RDD为(16, (1002, 'US')), (9, (1001, 'MX')), (1, (1004, 'MX')), (17, (1004, 'MX'))]
。我想制作一个新的RDD,(1002, (16, 'US')), (1001, (9, 'MX')), (1004, (1, 'MX')), (1004, (17, 'MX'))
和所需的新RDD
(1002, (16, 'US')), (1001, (9, 'MX')), (1004, (1, 'MX')), (1004, (17, 'MX'))
答案 0 :(得分:0)
rdd.map(lambda x:(x [1] [0],(x [0],x [1] [1])))