anonymity.tools.utils_k_anon package#

Submodules#

anonymity.tools.utils_k_anon.utils_k_anonymity module#

anonymity.tools.utils_k_anon.utils_k_anonymity.clear_white_spaces(table: DataFrame) DataFrame#

Deletes any white spaces from column names.

Parameters:

table (pandas dataframe) – dataframe with the data under study.

Returns:

table which columns don’t contain whitespaces.

Return type:

pandas dataframe

anonymity.tools.utils_k_anon.utils_k_anonymity.create_ranges(data, range_step)#
anonymity.tools.utils_k_anon.utils_k_anonymity.generalization(column: List | ndarray, hierarchies: dict, gen_level: int, name: str) List | ndarray | None#

Generalizes a column based on its data type.

Parameters:
  • column (list of values) – column from the table under study that needs to be generalized.

  • hierarchies (dictionary) – hierarchies for generalization of string columns.

  • gen_level (int) – Current level of generalization of each of the columns of the table.

  • name (string) – Name of the column that needs to be generalized.

Returns:

List of generalized values.

Return type:

list of values

anonymity.tools.utils_k_anon.utils_k_anonymity.string_to_interval(column: List | ndarray) List | ndarray#

Converts a string interval to an actual interval type, to facilitate the comparison of each data.

Parameters:

column (list of strings) – List of intervals as strings.

Returns:

List containing the intervals converted to the proper data type.

Return type:

list of intervals

anonymity.tools.utils_k_anon.utils_k_anonymity.suppress_identifiers(table: DataFrame, ident: List | ndarray) DataFrame#

Removes all the identifiers in the database.

Parameters:
  • table (pandas dataframe) – dataframe with the data under study.

  • ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.

Returns:

table with the identifiers fully anonymized.

Return type:

pandas dataframe

Module contents#