samedi 26 août 2017

Why wrong results coming when using 'in' in if condition?

I have two dataframes df1 contains 100K rows and df2 contains 6 million rows. I want to fix values for 'SoftDel???' column in df1 when 'id' matches in df2. code is working but results are wrong.

I have completed this task using merge and results are satisfactory but want to know why below is producing wrong results?

for x, y in df1.iterrows():
if y['id'] in df2['id']: df1.loc[x,'SoftDel???'] = 'No'

Aucun commentaire:

Enregistrer un commentaire