java - 如何在java中组合(连接)两个具有相同列名的数据帧

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40397206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:40:06  来源:igfitidea点击:

How can I combine(concatenate) two data frames with the same column name in java

javaapache-spark

提问by Seena V P

Can I append a dataframe to the right of other dataframe having same column names

我可以在具有相同列名的其他数据框的右侧附加一个数据框吗

采纳答案by Shankar

You can join two dataframes like this.

您可以像这样连接两个数据框。

df1.join(df2, df1.col("column").equalTo(df2("column")));

If you are looking for Union, then you can do something like this.

如果你正在寻找 Union,那么你可以做这样的事情。

df1.unionAll(df2);  // spark 1.6

Spark 2.0, unionAllwas renamed to union

Spark 2.0,unionAll更名为union