重複を保持しながら、この DataFrame と別の DataFrame の両方の行を含む新しい DataFrame を返します。
構文
intersectAll(other: "DataFrame")
パラメーター
| パラメーター | タイプ | 説明 |
|---|---|---|
other |
DataFrame | 結合する必要がある別の DataFrame。 |
返品
DataFrame: 結合された DataFrame。
メモ
これは、SQL での INTERSECT ALL と同じです。 SQL の標準として、この関数は列を (名前ではなく) 位置で解決します。
例示
df1 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3), ("c", 4)], ["C1", "C2"])
df2 = spark.createDataFrame([("a", 1), ("a", 1), ("b", 3)], ["C1", "C2"])
result_df = df1.intersectAll(df2).sort("C1", "C2")
result_df.show()
# +---+---+
# | C1| C2|
# +---+---+
# | a| 1|
# | a| 1|
# | b| 3|
# +---+---+
df1 = spark.createDataFrame([(1, "A"), (2, "B")], ["id", "value"])
df2 = spark.createDataFrame([(2, "B"), (3, "C")], ["id", "value"])
result_df = df1.intersectAll(df2).sort("id", "value")
result_df.show()
# +---+-----+
# | id|value|
# +---+-----+
# | 2| B|
# +---+-----+