Extract column values of Dataframe as List in Apache Spark

后端 未结 10 1064
慢半拍i
慢半拍i 2020-12-22 16:52

I want to convert a string column of a data frame to a list. What I can find from the Dataframe API is RDD, so I tried converting it back to RDD first, and then

10条回答
  •  情歌与酒
    2020-12-22 17:27

    An updated solution that gets you a list:

    dataFrame.select("YOUR_COLUMN_NAME").map(r => r.getString(0)).collect.toList
    

提交回复
热议问题