Python Pandas - Find difference between two data frames

前端 未结 10 1917
陌清茗
陌清茗 2020-11-22 13:59

I have two data frames df1 and df2, where df2 is a subset of df1. How do I get a new data frame (df3) which is the difference between the two data frames?

In other w

10条回答
  •  春和景丽
    2020-11-22 14:38

    A slight variation of the nice @liangli's solution that does not require to change the index of existing dataframes:

    newdf = df1.drop(df1.join(df2.set_index('Name').index))
    

提交回复
热议问题