ConvertColumnsOp¶
- class ConvertColumnsOp(parameters)[source]
Convert specified columns to have specified data type.
- Required remodeling parameters:
column_names (list): The list of columns to convert.
convert_to (str): Name of type to convert to. (One of ‘str’, ‘int’, ‘float’, ‘fixed’.)
- Optional remodeling parameters:
decimal_places (int): Number decimal places to keep (for fixed only).
Notes:
Methods
|
Constructor for the convert columns operation. |
|
Convert the specified column to a specified type. |
|
Additional validation required of operation parameters not performed by JSON schema validator. |
Attributes
- ConvertColumnsOp.__init__(parameters)[source]¶
Constructor for the convert columns operation.
- Parameters:
parameters (dict) – Parameter values for required and optional parameters.
- ConvertColumnsOp.do_op(dispatcher, df, name, sidecar=None)[source]¶
Convert the specified column to a specified type.
- Parameters:
dispatcher (Dispatcher) – Manages the operation I/O.
df (DataFrame) – The DataFrame to be remodeled.
name (str) – Unique identifier for the dataframe – often the original file path.
sidecar (Sidecar or file-like) – Only needed for HED operations.
- Returns:
A new DataFrame with the factor columns appended.
- Return type:
DataFrame
- static ConvertColumnsOp.validate_input_data(operations)[source]¶
Additional validation required of operation parameters not performed by JSON schema validator.
- ConvertColumnsOp.NAME = 'convert_columns'¶
- ConvertColumnsOp.PARAMS = {'additionalProperties': False, 'if': {'properties': {'convert_to': {'const': 'fixed'}}}, 'properties': {'column_names': {'description': 'List of names of the columns whose types are to be converted to the specified type.', 'items': {'type': 'string'}, 'minItems': 1, 'type': 'array', 'uniqueItems': True}, 'convert_to': {'description': 'Data type to convert the columns to.', 'enum': ['str', 'int', 'float', 'fixed'], 'type': 'string'}, 'decimal_places': {'description': 'The number of decimal points if converted to fixed.', 'type': 'integer'}}, 'required': ['column_names', 'convert_to'], 'then': {'required': ['decimal_places']}, 'type': 'object'}¶