In [2]:
lines = sc.parallelize(["hello world", "hi"])

words_map = lines.map(lambda line: line.split(" ")).coalesce(1)
words_flat_map = lines.flatMap(lambda line: line.split(" ")).coalesce(1)
print "words with map : {}".format(words_map.collect())
print "words with flat map: {}".format(words_flat_map.collect())


words with map : [['hello', 'world'], ['hi']]
words with flat map: ['hello', 'world', 'hi']