pgcom.commuter.Commuter.encode_composite_category¶
- Commuter.encode_composite_category(data: pandas.core.frame.DataFrame, categories: Dict[str, str], key: str, category_table: str, key_name: Optional[str] = None, na_value: Optional[str] = None) pandas.core.frame.DataFrame [source]¶
Encode categories represented by multiple columns.
Implements writing of all the unique combinations given by multiple columns in DataFrame to the table given by
category_table
.Dictionary
categories
provides a mapping between DataFrame andcategory_table
column names.- Parameters
data – Pandas.DataFrame with categorical columns.
categories – Dictionary provided the mapping between column names. Dict keys provide names of columns in
data
represented category, values represent column names incategory_table
.key – Name of the DataFrame column with encoded values.
category_table – Name of the table with stored categories.
key_name – Name of the column in
category_table
contained the encoded values. Defaults tokey
.na_value – Missing data representation.
- Returns
Pandas.DataFrame with encoded category.