How to extract rows in a dataframe that do not exist in another

后端 未结 3 860
忘掉有多难
忘掉有多难 2020-12-11 22:14

I have two dataframes:

all_data:

              AID       VID  Freq
0        00016A3E  0127C661     1
1        00016A3E  0C05DA5D     2
2        0001         


        
3条回答
  •  我在风中等你
    2020-12-11 22:35

    This worked for me:

    merged = all_data.merge(subset, how='left', indicator=True)
    print(merged[merged['_merge']=='left_only'])
    

    After the merge, you can filter by the _merge with left_only value.

提交回复
热议问题