0

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
  • 1
    Check out this question: https://stackoverflow.com/questions/39880627/in-pandas-how-to-delete-rows-from-a-data-frame-based-on-another-data-frame – D.Manasreh Apr 27 '22 at 14:38

1 Answers1

2

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
Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52