'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:

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 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ynjxsjmh