Skip to content
Advertisement

Check if a row in one DataFrame exist in another, BASED ON SPECIFIC COLUMNS ONLY

I have two Pandas DataFrame with different columns number.

df1 is a single row DataFrame:

JavaScript

df2, instead, is multiple rows Dataframe:

JavaScript

I would to verify if the df1’s row is in df2, but considering X0 AND Y0 columns only, ignoring all other columns. In this example the df1’s row match the df2’s row at index 3, that have 100 in X0 and ‘shark’ in Y0.

The output for this example is:

JavaScript

Note: True/False as output is enough for me, I don’t care about index of matched row.

I founded similar questions but all of them check the entire row…

Advertisement

Answer

duplicated

JavaScript

Save a tad bit of time

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement