def pseudonymize_row(row): """ Replace some identifying information with others: - Fake name - Birthdate is replaced with the age """ anonymized_row = row.copy() # using Faker (https://faker.readthedocs.io/en/master/), we generate fake names if anonymized_row['Gender'] == 'Female': anonymized_row['Fullname'] = faker.name_female() else: anonymized_row['Fullname'] = faker.name_male() del anonymized_row['Birthdate'] birthdate = datetime.strptime(row['Birthdate'], '%Y-%m-%d') age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) anonymized_row['Age'] = age return anonymized_row