macpie.util.MaskMap#

class macpie.util.MaskMap(dict=None, /, **kwargs)#

A dict that maps IDs (ints) to a namedtuple containing the following named fields:

  • masked_id: a replacement ID

  • day_shift: a random number between 365 and 730 used to shift date values backwards by

This class is meant to be used by Masker for masking dataframes, but can be used for other purposes.

__init__(dict=None, /, **kwargs)#

Methods

__init__([dict])

clear()

copy()

from_csv_file(filepath[, day_shift, headers])

Construct MaskMap from a csv file, usually generated by to_csv_file().

from_id_range(min_id, max_id[, day_shift, ...])

Create a map given a range of IDs (ints)

fromkeys(iterable[, value])

get(k[,d])

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

print()

Print a representation table suited to a terminal in grid format.

setdefault(k[,d])

to_csv([headers])

to_csv_file(filepath[, headers])

to_flat_rows()

to_tablib([headers])

Convert to a tablib.Dataset.

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes

headers

mask_map