How to LEFT ANTI join under some matching condition

后端 未结 1 1380
孤街浪徒
孤街浪徒 2021-02-02 14:39

I have two tables - one is a core data with a pair of IDs (PC1 and P2) and some blob data (P3). The other is a blacklist data for PC1 in the former table. I will call the first

1条回答
  •  失恋的感觉
    2021-02-02 15:07

    Pass the join conditions as a list to the join function, and specify how='left_anti' as the join type:

    in_df.join(
        blacklist_df, 
        [in_df.PC1 == blacklist_df.P1, in_df.P2 == blacklist_df.B1], 
        how='left_anti'
    ).show()
    
    +---+---+---+
    |PC1| P2| P3|
    +---+---+---+
    |  1|  3|  D|
    |  4| 11|  D|
    |  3|  1|  C|
    +---+---+---+
    

    0 讨论(0)
提交回复
热议问题