I have a two data frame df1 (35k record) and df2(100k records). In df1['col1'] and df2['col3'] i have unique id's. I want to match df1['col1'] with df2['col3']. If they match, I want to update df1 with one more column say df1['Match'] with value true and if not match, update with False value. I want to map this TRUE and False value against Matching and non-matching record only.
I am using .isin()function, I am getting the correct match and not match count but not able to map them correctly.
Match = df1['col1'].isin(df2['col3'])
df1['match'] = Match
I have also used merge function using by passing the parameter how=rightbut did not get the results.
df1['match'] = df1['col1'].isin(df2['col3'])seems to work for your described goal. Rows ofdf1whosecol1value is found indf2['col3']will be True, otherwise False.df1['match'] = Match, if I have 10 records matching. then in df1 it is just getting updated in serial wise but not to the exact record it is matching.df1['col1'].isin(df2['col3'])is equal to the number of rows ofdf1regardless of how many matching "True" records found. You can try @crazyGamer answer but your code should work fine. Maybe something else is wrong.