ConvertColumnsOp

class ConvertColumnsOp(parameters)[source]

Convert.

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’.)

  • decimal_places (int): Number decimal places to keep (for fixed only).

Methods

hed.tools.remodeling.operations.convert_columns_op.ConvertColumnsOp.__init__(...)

Constructor for the convert columns operation.

hed.tools.remodeling.operations.convert_columns_op.ConvertColumnsOp.check_parameters(...)

Verify that the parameters meet the operation specification.

hed.tools.remodeling.operations.convert_columns_op.ConvertColumnsOp.do_op(...)

Convert the specified column to a specified type.

Attributes

hed.tools.remodeling.operations.convert_columns_op.ConvertColumnsOp.PARAMS

ConvertColumnsOp.__init__(parameters)[source]

Constructor for the convert columns operation.

Parameters:

parameters (dict) – Parameter values for required and optional parameters.

Raises:
  • KeyError

    • If a required parameter is missing.

    • If an unexpected parameter is provided.

  • TypeError

    • If a parameter has the wrong type.

  • ValueError

    • If convert_to is not one of the allowed values.

ConvertColumnsOp.check_parameters(parameters)

Verify that the parameters meet the operation specification.

Parameters:

parameters (dict) – Dictionary of parameters for this operation.

Raises:
  • KeyError

    • If a required parameter is missing.

    • If an unexpected parameter is provided.

  • TypeError

    • If a parameter has the wrong type.

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

ConvertColumnsOp.PARAMS = {'operation': 'convert_columns', 'optional_parameters': {'decimal_places': <class 'int'>}, 'required_parameters': {'column_names': <class 'list'>, 'convert_to': <class 'str'>}}