python pandas dataframe find row containing specific value and return boolean

I want compare two dataframes which is df1 and df2. df1 is a data that updates every hour by it self. df2 is a dataframe that alreay exists. I want to append specific row that is updated.

for example, Here is df1


which contains 5 rows of information

and df2 which already existed


we can tell that eric is added but df2 is not representing that.

I could overwrite df2 with df1 but I shouldn't as there will be remark that will be updated by person later the data is written.

So, I decided to remove each rows of data by finding it from df2 by its id, and remove them with for loop

and after that, there will be only eric's row will remain which will make me possible to just append eric to df2.

So what I tried is this

for index, row in df1.iterrows():
    id = row['id']
    if df2.loc[df1['id'].isin(id)] = True:
        df1[ != id)

and it returns syntax error....

am I on the right track? is it will be the best solution to solve this problem?and how should I change the code to achieve my goal?

0 Comment



Captcha image