我有一些元组列表,我想将它们组合成一个列表。我已经能够使用 lambda 和列表理解来处理数据,我已经接近能够使用 reduceByKey 但不确定如何合并列表。那么格式...
[[(0, 14), (0, 24)], [(1, 19), (1, 50)], ...]
我希望它是这样的......
[(0, 14), (0, 24), (1, 19), (1, 50), ...]
让我到达我需要去的地方的代码......
test = test.map(lambda x: (x[1], [e * local[x[1]] for e in x[0]]))
test = test.map(lambda x: [(x[0], y) for y in x[1]])
但不确定从那里如何合并列表