FactorColumnOp

class FactorColumnOp(parameters)[source]

Create tabular file factor columns from column values.

Required remodeling parameters:
  • column_name (str): The name of a column in the DataFrame.

  • factor_values (list): Values in the column column_name to create factors for.

  • factor_names (list): Names to use as the factor columns.

Methods

hed.tools.remodeling.operations.factor_column_op.FactorColumnOp.__init__(...)

Constructor for the factor column operation.

hed.tools.remodeling.operations.factor_column_op.FactorColumnOp.check_parameters(...)

Verify that the parameters meet the operation specification.

hed.tools.remodeling.operations.factor_column_op.FactorColumnOp.do_op(...)

Create factor columns based on values in a specified column.

Attributes

hed.tools.remodeling.operations.factor_column_op.FactorColumnOp.PARAMS

FactorColumnOp.__init__(parameters)[source]

Constructor for the factor column 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 factor_names is not empty and is not the same length as factor_values.

FactorColumnOp.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.

FactorColumnOp.do_op(dispatcher, df, name, sidecar=None)[source]

Create factor columns based on values in a specified column.

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) – Not needed for this operation.

Returns:

A new DataFrame with the factor columns appended.

Return type:

DataFrame

FactorColumnOp.PARAMS = {'operation': 'factor_column', 'optional_parameters': {}, 'required_parameters': {'column_name': <class 'str'>, 'factor_names': <class 'list'>, 'factor_values': <class 'list'>}}