I am new to Python and need a bit of help with comparing data from two different dataframes.
What I'm trying to do is compare a column "New" from the second_dataset (dataframe) with the "New" column from the first_dataset (dataframe). If the value in the row in second_dataset exists in first_dataset, I would like to add in a "Status column" and add the string "Yes" to it else I want it to say "No". I've copied my code below.
So far I've tried a few things but keep getting an error. Any suggestions would be helpful. Please.
for row in second_dataset["New"]:
if row in first_dataset["New"] == second_dataset["New"]:
second_dataset["Status"] = "Yes"
elif row != first_dataset["New"]:
second_dataset["Status"] = "No"
else:
second_dataset["Status"] = "Error"