import pandas as pd # Constants FILE_PATH = 'ps (30).xlsx' SHEET_NAME = 'ps (30)' COLUMN_NAME = 'Student-ID' def find_duplicates(file_path, sheet_name, column_name): df = pd.read_excel(file_path, sheet_name=sheet_name) duplicate_ids = df[df.duplicated(subset=[column_name], keep=False)][column_name] unique_duplicate_ids = duplicate_ids.drop_duplicates() return unique_duplicate_ids def main(): unique_duplicate_ids = find_duplicates(FILE_PATH, SHEET_NAME, COLUMN_NAME) num_duplicates = len(unique_duplicate_ids) if not unique_duplicate_ids.empty: print(f"Duplicated {COLUMN_NAME} values (count: {num_duplicates}):") print(unique_duplicate_ids) else: print("No duplicates found.") if __name__ == "__main__": main()