Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to exclude data present on another dataframe?

I’m trying to exclude data that is filtered on another data frame using pandas jupyter. An example of the data frame can be seen below.

Data frame 1:

ID Amount
AB-01 2.65
AB-02 3.6
AB-03 5.6
AB-04 7.6
AB-05 2

Dataframe 2:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ID Amount
AB-01 2.65
AB-02 3.6

Desired outcome:

ID Amount
AB-03 5.6
AB-04 7.6
AB-05 2

>Solution :

You can use isin

out = df1[~df1['ID'].isin(df2['ID'])]
print(out)

      ID  Amount
2  AB-03     5.6
3  AB-04     7.6
4  AB-05     2.0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading