123456789101112131415161718 |
- def pseudonymize(self, size=None):
- """
- Return pseudonymized values for this attribute, which is used to
- substitute identifiable data with a reversible, consistent value.
- """
- size = size or self.size
- if size != self.size:
- attr = Series(np.random.choice(self.bins, size=size, p=self.prs))
- else:
- attr = self
- if self.categorical:
- mapping = {b: utils.pseudonymise_string(b) for b in self.bins}
- return attr.map(lambda x: mapping[x])
- if self.type == 'string':
- return attr.map(utils.pseudonymise_string)
- elif self.is_numerical or self.type == 'datetime':
- return attr.map(str).map(utils.pseudonymise_string)
|