【发布时间】:2019-08-26 16:36:13
【问题描述】:
我有 2 个这样的 DataFrame:
+--+-----------+
|id|some_string|
+--+-----------+
| a| foo|
| b| bar|
| c| egg|
| d| fog|
+--+-----------+
还有这个:
+--+-----------+
|id|some_string|
+--+-----------+
| a| hoi|
| b| hei|
| c| hai|
| e| hui|
+--+-----------+
我想加入他们成为这样的人:
+--+-----------+
|id|some_string|
+--+-----------+
| a| foohoi|
| b| barhei|
| c| egghai|
| d| fog|
| e| hui|
+--+-----------+
因此,第一个数据帧中的 some_string 列连接到第二个数据帧中的 some_string 列。如果我正在使用
df_join = df1.join(df2,on='id',how='outer')
它会返回
+--+-----------+-----------+
|id|some_string|some_string|
+--+-----------+-----------+
| a| foo| hoi|
| b| bar| hei|
| c| egg| hai|
| d| fog| null|
| e| null| hui|
+--+-----------+-----------+
有什么办法吗?
【问题讨论】:
标签: python pyspark pyspark-dataframes