I have 2 dataframes that both has UserID column (df1 and df2)
I want to create a column in df1 where the value would be 1 if ID exists at least once and 0 else. The issue I'm running to is that since the UserID value is int, it will match a shorter ID as part of a longer ID and still return 1 (e.g. record for UserID: 123 will return 1 if df2 has UserID 12345) How can I create a new column with exact match?
This is the code I tried so far.
df1['Exists'] = [1 if x in df2['UserID'] else 0 for x in df1['UserID']]