简体   繁体   English

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

[英]Spark Scala copy column from one dataframe to another

I have a modified version of the original dataframe on which I did clustering, Now I want to bring the predicted column back to the original DF (the index is ok, so it matches). 我有一个在其上进行聚类的原始数据帧的修改版本,现在我想将预测的列带回原始DF(索引正常,因此匹配)。 How am I supposed to do this? 我应该怎么做? With this code I get an error. 有了这段代码,我得到一个错误。

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)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Spark Scala检查一个数据框列中的值是否在另一数据框列中存在 - Check if value from one dataframe column exists in another dataframe column using Spark Scala Scala Spark - 将数据从 1 Dataframe 复制到另一个具有嵌套模式和相同列名的 DF - Scala Spark - copy data from 1 Dataframe into another DF with nested schema & same column names 从火花的多列创建一个 dataframe - Scala eqv 的 Python - Create one from multiple column of a spark dataframe - Scala eqv of Python Scala/Spark - 使用另一数据集中的一列创建数据集 - Scala/Spark - Create Dataset with one column from another Dataset 如何在 Spark 数据框中将值从一列交换到另一列 - How to swap the values from one column to another in Spark dataframe 从DataFrame选择Spark Scala动态列 - Spark Scala Dynamic column selection from DataFrame 根据Apache Spark Scala中的列数据类型将数据框中的列选择为另一个数据框 - Select columns from a dataframe into another dataframe based on column datatype in Apache Spark Scala Spark Scala数据框-用来自另一个数据框的值替换/联接列值(但已转置) - Spark Scala Dataframe - replace/join column values with values from another dataframe (but is transposed) Scala Spark基于数据帧中的另一列增加一列而不使用for循环 - Scala Spark Incrementing a column based on another column in dataframe without for loops 使用 Spark Dataframe (Scala) 中的另一列数组创建一列数组 - Creating a column of array using another column of array in a Spark Dataframe (Scala)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM