HackHPC / utils.py
Seanyoon's picture
Create utils.py
7ac57cf
raw
history blame contribute delete
No virus
645 Bytes
import random
import string
def anonymize_column(col):
"""
Anonymizes a column by replacing all values with a random string of 10 characters.
Args:
col (pandas.Series): A pandas Series object representing a column of data.
Returns:
pandas.Series: The anonymized column as a pandas Series object.
"""
def generate_random_string():
"""
Generates a random string of 10 characters.
Returns:
str: The random string.
"""
return ''.join(random.choices(string.ascii_letters + string.digits, k=10))
return col.apply(lambda x: generate_random_string())