python flat map code example
Example 1: flatmap python
array = [[1, 2], [3, 4]]
flatArray = [element for element in innerArray for innerArray in array]
# [1, 2, 3, 4]
Example 2: flatmap in python
rdd2=rdd.flatMap(lambda x: x.split(" "))
for element in rdd2.collect():
print(element)