Utils¶
Miscellaneous functions and helpers for the uclasm package.
-
one_hot(idx, length)¶ Return a 1darray of zeros with a single one in the idx’th entry.
-
index_map(args)¶ Return a dict mapping elements to their indices.
Parameters: args (Iterable[str]) – Strings to be mapped to their indices.
-
invert(dict_of_sets)¶ TODO: Docstring.
-
values_map_to_same_key(dict_of_sets)¶ TODO: Docstring.
-
apply_index_map_to_cols(df, cols, values)¶ Replace df[cols] with their indexes as taken from names.
Parameters: - df (DataFrame) – To be modified inplace.
- cols (Iterable[str]) – Columns of df to operate on.
- values (Iterable[str]) – Values expected to be present in df[cols] to be replaced with their corresponding indexes.