Skip to content Skip to sidebar Skip to footer

Get Rows That Are Present In One Dataframe, But Not The Other

I'd like to extract those rows from df1 which are not existent in df2 (identity is the index). For the below example, I would expect the first row in df1 to be returned. Unfortunat

Solution 1:

set_index is not in place by default, so df1 and df2 still have their numeric index after the call. Do either

df2.set_index(..., inplace=True)

or

df2 = df2.set_index(...)

You will see that by far the most methods in pandas work that way.

Post a Comment for "Get Rows That Are Present In One Dataframe, But Not The Other"