Extract column values of Dataframe as List in Apache Spark

后端 未结 10 1065
慢半拍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:38

    List whatever_list = df.toJavaRDD().map(new Function() {
        public String call(Row row) {
            return row.getAs("column_name").toString();
        }
    }).collect();
    
    logger.info(String.format("list is %s",whatever_list)); //verification
    

    Since no one has given any solution in java(Real Programming Language) Can thank me later

提交回复
热议问题