How to convert DataFrame to RDD in Scala?

后端 未结 3 1344
甜味超标
甜味超标 2021-02-01 02:11

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

3条回答
  •  天涯浪人
    2021-02-01 02:35

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

    df.map(row => (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.

提交回复
热议问题