replacer
replacer
¶
Tabular PII replacement interface.
Classes:
| Name | Description |
|---|---|
TabularPiiReplacer |
Replace PII in a dataframe through one plan-driven interface. |
TabularPiiReplacer(config, *, data_config, time_series=None)
¶
Replace PII in a dataframe through one plan-driven interface.
The replacement module owns plan resolution, DAG execution, free-text span
detection and rewriting, positional row identity, scope keys, synthetic
value generation, and statistics. replace returns a new dataframe and
never mutates the caller's frame or writes artifacts. The pipeline remains
responsible for deciding whether and where to persist the resolved
configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ReplacePiiConfig
|
PII replacement configuration, including the replacement plan. |
required |
data_config
|
DataParameters
|
Input data configuration used to validate and execute the resolved plan. |
required |
time_series
|
TimeSeriesParameters | None
|
Optional time-series configuration used to protect ordering and grouping columns. |
None
|
Methods:
| Name | Description |
|---|---|
replace |
Return a replacement result for |
detect |
Return the column statistics |
Source code in src/nemo_safe_synthesizer/pii_replacer/replacer.py
replace(df, *, capture_replacement_map=False, check_pattern_coverage=True)
¶
Return a replacement result for df without mutating df.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe whose planned PII values should be replaced. |
required |
capture_replacement_map
|
bool
|
Include sensitive per-occurrence replacement provenance and accepted free-text span traces in the result. The default leaves this data unavailable so ordinary calls do not accidentally persist original PII. |
False
|
check_pattern_coverage
|
bool
|
Require each pattern to cover at least 99%
of |
True
|
Raises:
| Type | Description |
|---|---|
ParameterError
|
If the configured plan is invalid for |
GenerationError
|
If a replacement cannot be generated. |
Source code in src/nemo_safe_synthesizer/pii_replacer/replacer.py
detect(df, *, check_pattern_coverage=True)
¶
Return the column statistics replace would report for df, without replacing anything.
The plan is resolved and PII is detected exactly as in replace, but no replacement value is
generated and df is not copied or changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe whose PII should be detected. |
required |
check_pattern_coverage
|
bool
|
Same as for |
True
|
Raises:
| Type | Description |
|---|---|
ParameterError
|
If the configured plan is invalid for |
GenerationError
|
If free-text detection fails. |