1

I have some logic that checks if the id of a specific row appears in another column of the same dataframe for the same row. If the id appears in df['list_of_approved_id'] then I change the value of the field df['flag'] to 1.

df['flag'] = 0  

for ind in df.index:
  if df['id'][ind] in (df['list_of_approved_id'][ind]):
     df['flag'][ind] = 1 

The logic was running fine in the past but now it's much slowe. I'm trying to rewrite this logic into something more pythonic that would be running faster. Looking for help for optimising this logic! Any help is appreciated!

Hugo Wolf
  • 69
  • 7

0 Answers0