How to convert DataFrame to RDD in Scala?

Can someone please share how one can convert a dataframe to an RDD?


val rows: RDD[Row] = df.rdd

Use => ...) to convert the dataframe to a RDD if you want to map a row to a different RDD element. For example => (row(1), row(2)))

gives you a paired RDD where the first column of the df is the key and the second column of the df is the value.