Explode function basically takes in an array or a map as an input and outputs the elements of the array (map) as separate rows.
Also, I would like to tell you that explode and split are SQL functions. Both of them operate on SQL Column.
Now if you want to separate data on arbitrary whitespace you'll need something like this:
df = sqlContext.createDataFrame(
[('cat \n\n elephant rat \n rat cat', )], ['word']
)
df.select(explode(split(col("word"), "\s+")).alias("word")).show()
## +--------+
## | word|
## +--------+
## | cat|
## |elephant|
## | rat|
## | rat|
## | cat|
## +--------+