Spaces:
Runtime error
Runtime error
| 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()) | |