Spark Scala复制列从一个数据帧到另一个数据帧

时间:2018-06-06 10:06:55

标签: scala apache-spark dataframe apache-spark-sql

我有原始数据框的修改版本,我在其上进行了聚类, 现在我想将预测列恢复到原始DF(索引正常,因此它匹配)。我该怎么做? 使用此代码,我收到错误。

println("Predicted:")
dfWithOutput.show
println("Original:")
originalDF = originalDF.withColumn("cluster", dfWithOutput.col("prediction")

Exception in thread "main" org.apache.spark.sql.AnalysisException: Resolved attribute(s) prediction#2121 missing from (list of columns in the original df)

1 个答案:

答案 0 :(得分:3)

您需要加入两个数据框,然后选择您感兴趣的列

相关问题