How do I change this code for searching duplicats in python ? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How do I change this code for searching duplicats in python ? (/thread-32929.html) |
How do I change this code for searching duplicats in python ? - Eidrizi - Mar-17-2021 This is the code that I use for searching duplicates in my excel sheet : def check_duplicacy(first_col): first_col_list = first_col.tolist() aux_first_col = [] for i in range(len(first_col_list)): if not(pd.isnull(first_col_list[i])): if(first_col_list[i] in aux_first_col): print('Duplicate found in row nunmber:'+ str(first_col_list[i])) return first_col_list[i] else: aux_first_col.append(first_col_list[i]) print("No duplicacy found") return ""The code works fine just when I have long list of duplicates it runs for ever. How can I change that the moment find an error stops from the loop.? Best regards, Eidrizi |