ts_shape.context.value_mapping
¤
Classes:
-
ValueMapper
–A class to map values from specified columns of a DataFrame using a mapping table (CSV or JSON file),
ValueMapper
¤
ValueMapper(dataframe: DataFrame, mapping_file: str, map_column: str, mapping_key_column: str, mapping_value_column: str, file_type: str = 'csv', sep: str = ',', encoding: str = 'utf-8', column_name: str = 'systime')
Bases: Base
A class to map values from specified columns of a DataFrame using a mapping table (CSV or JSON file), inheriting from the Base class.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame to be processed and mapped.
-
mapping_file
¤str
) –The file path of the mapping table (CSV or JSON).
-
map_column
¤str
) –The name of the column in the DataFrame that needs to be mapped.
-
mapping_key_column
¤str
) –The column in the mapping table to match with values from the DataFrame.
-
mapping_value_column
¤str
) –The column in the mapping table containing the values to map to.
-
file_type
¤str
, default:'csv'
) –The type of the mapping file ('csv' or 'json'). Defaults to 'csv'.
-
sep
¤str
, default:','
) –The separator for CSV files. Defaults to ','.
-
encoding
¤str
, default:'utf-8'
) –The encoding to use for reading the file. Defaults to 'utf-8'.
-
column_name
¤str
, default:'systime'
) –The name of the column to sort the DataFrame by in the base class. Defaults to 'systime'.
Methods:
-
get_dataframe
–Returns the processed DataFrame.
-
map_values
–Maps values in the specified DataFrame column based on the mapping table.
Source code in src/ts_shape/context/value_mapping.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
get_dataframe
¤
get_dataframe() -> DataFrame
Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
34 35 36 |
|
map_values
¤
map_values() -> DataFrame
Maps values in the specified DataFrame column based on the mapping table.
Returns:
-
DataFrame
–pd.DataFrame: A new DataFrame with the mapped values.
Source code in src/ts_shape/context/value_mapping.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|