Suppose I have a pandas df like the following. For each item, such as python, it has the top3 similar items in top1, top2, top3, and their similarity scores score1, score2, score3. I want to set the top N item as empty string if the similarity score is below 0.8. For each row, if all scores are below 0.8, then drop this row totally.
0 top1 top2 top3 score1 score2 score3
0 python perl php java 0.9 0.7 0.4
1 coke diel_coke pepsi taco 0.85 0.9 0.23
2 apple car house hill 0.3 0.1 0.05
So the dataframe will become the following after the drop:
0 top1 top2 top3 score1 score2 score3
0 python perl 0.9
1 coke diel_coke pepsi 0.85 0.9
If I iterate the df row by row, it seems very slow if the df is big. How can I achieve the purpose without iterating row by row?