Skip to content

Commit 61998c3

Browse files
committed
fix: fix apply_transformation function
1 parent 79e6b16 commit 61998c3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

anjana/anonymity/utils/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pandas as pd
2121
from beartype import beartype
2222
from beartype import typing
23+
from copy import copy
2324

2425

2526
@beartype()
@@ -192,15 +193,15 @@ def get_transformation(
192193

193194
@beartype()
194195
def apply_transformation(
195-
data_anon: pd.DataFrame,
196+
data: pd.DataFrame,
196197
quasi_ident: typing.Union[typing.List, np.ndarray],
197198
hierarchies: dict,
198199
transformation: list,
199200
) -> pd.DataFrame:
200201
"""Apply a given transformation to the data.
201202
202-
:param data_anon: data under study.
203-
:type data_anon: pandas dataframe
203+
:param data: data under study.
204+
:type data: pandas dataframe
204205
205206
:param quasi_ident: list with the name of the columns of the dataframe
206207
that are quasi-identifiers.
@@ -216,6 +217,7 @@ def apply_transformation(
216217
:return: dataset generalized with the transformation given
217218
:rtype: pandas dataframe
218219
"""
220+
data_anon = copy(data)
219221
actual_transform = check_gen_level(data_anon, quasi_ident, hierarchies)
220222
for i, qi in enumerate(quasi_ident):
221223
hierarchy_qi = hierarchies[qi]

0 commit comments

Comments
 (0)