Flatmap Python
array = [[1, 2], [3, 4]]
flatArray = [element for element in innerArray for innerArray in array]
# [1, 2, 3, 4]
Frustrated Developer
array = [[1, 2], [3, 4]]
flatArray = [element for element in innerArray for innerArray in array]
# [1, 2, 3, 4]
rdd2=rdd.flatMap(lambda x: x.split(" "))
for element in rdd2.collect():
print(element)