我有以下 DF
ID NAME VAL
-----------
1 John 5
2 Anna 6
3 Josh 12
4 Paul 10
我有這個 DF
ID
--
2
3
我正在使用 pyspark 和以下代碼進行 left_anti 連接
test= df.join(
df_ids,
on=['ID'],
how='left_anti'
)
我的預期輸出是:
ID NAME VAL
1 John 5
4 Paul 10
雖然,當我運行上面的代碼時,我得到了一個空的資料幀作為輸出。我究竟做錯了什么?
uj5u.com熱心網友回復:
您可以通過以下方式做到這一點。
df = (df.join(df_ids, on=df["ID"]==df_ids["ID"], how='left')
.where(df_ids["ID"].isNull())
.select(df["*"]))
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/383927.html
