File size: 645 Bytes
7ac57cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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())