I have two DataFrames of unequal lengths, Alerts and Labels. They both have a column named ID. I want to create a new column in the DataFrame Labels with true if its ID matches any ID in Alerts and false the ID is not present in Alerts.
CodePudding user response:
Assuming Labels
and Alerts
as dataframe names:
Labels['new_col'] = Labels['ID'].apply(lambda x:True if x in Alerts['ID'] else False)