RemoveColumnsOp

class RemoveColumnsOp(parameters)[source]

Remove columns from a tabular file.

Required remodeling parameters:
  • column_names (list): The names of the columns to be removed.

  • ignore_missing (boolean): If true, names in column_names that are not columns in df should be ignored.

Methods

hed.tools.remodeling.operations.remove_columns_op.RemoveColumnsOp.__init__(...)

Constructor for remove columns operation.

hed.tools.remodeling.operations.remove_columns_op.RemoveColumnsOp.check_parameters(...)

Verify that the parameters meet the operation specification.

hed.tools.remodeling.operations.remove_columns_op.RemoveColumnsOp.do_op(...)

Remove indicated columns from a dataframe.

Attributes

hed.tools.remodeling.operations.remove_columns_op.RemoveColumnsOp.PARAMS

RemoveColumnsOp.__init__(parameters)[source]

Constructor for remove columns operation.

Parameters:

parameters (dict) – Dictionary with the 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.

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

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

Remove indicated columns from a dataframe.

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 after processing.

Return type:

Dataframe

Raises:

KeyError

  • If ignore_missing is False and a column not in the data is to be removed.

RemoveColumnsOp.PARAMS = {'operation': 'remove_columns', 'optional_parameters': {}, 'required_parameters': {'column_names': <class 'list'>, 'ignore_missing': <class 'bool'>}}