如何将Spark Dataframe添加到另一个数据框的底部? [英] How to add a Spark Dataframe to the bottom of another dataframe?
本文介绍了如何将Spark Dataframe添加到另一个数据框的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用 withcolumn
向Dataframe添加新列。但是在scala中,如何向DataFrame添加新行呢?
I can use withcolumn
to add new columns to a Dataframe. But in scala how can I add new rows to a DataFrame?
我正在尝试将数据框添加到另一个底部。因此,如何在scala中添加行或如何将DataFrame添加到另一个的底部将有所帮助。谢谢
I'm trying to add a dataframe to the bottom of another one. So either how to add rows in scala or how to add a DataFrame to the bottom of another one will help. Thanks
推荐答案
If they have the same schema, simply use union
for spark 2+:
val dfUnion = df1.union(df2)
或 unionAll
for spark 1 +:
Or unionAll
for spark 1+:
val dfUnion = df1.unionAll(df2)
这篇关于如何将Spark Dataframe添加到另一个数据框的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文