samedi 23 mars 2019

Exclude rows in a dataframe based on matching values in rows from another dataframe

I have two dataframes (A and B). I want to remove all the rows in B where the values for columns Month, Year, Type, Name are an exact match.

Dataframe A

   Name    Type   Month   Year  country Amount   Expiration  Paid
0 EXTRON   GOLD   March   2019    CA    20000   2019-09-07   yes
0 LEAF    SILVER  March   2019    PL    4893    2019-02-02   yes       
0 JMC     GOLD    March   2019    IN    7000    2020-01-16   no       

Dataframe B

  Name     Type   Month   Year  country Amount   Expiration  Paid
0 JONS    GOLD    March   2018    PL    500     2019-10-17   yes
0 ABBY    BRONZE  March   2019    AU    60000   2019-02-02   yes       
0 BUYT     GOLD   March   2018    BR     50     2018-03-22   no       
0 EXTRON  GOLD    March   2019    CA    90000   2019-09-07   yes
0 JAYB    PURPLE  March   2019    PL    9.90    2018-04-20   yes       
0 JMC     GOLD    March   2019    IN    6000    2020-01-16   no       
0 JMC     GOLD    April   2019    IN    1000    2020-01-16   no      

Desired Output:

Dataframe B

  Name       Type   Month   Year  country Amount   Expiration  Paid
0 JONS    GOLD    March   2018    PL    500     2019-10-17   yes
0 ABBY    BRONZE  March   2019    AU    60000   2019-02-02   yes       
0 BUYT     GOLD   March   2018    BR     50     2018-03-22   no       
0 JAYB    PURPLE  March   2019    PL    9.90    2018-04-20   yes       
0 JMC     GOLD    April   2019    IN    1000    2020-01-16   no

Aucun commentaire:

Enregistrer un commentaire