SplitRowsOp

class SplitRowsOp(parameters)[source]

Split rows in a tabular file into multiple rows based on parameters.

Required remodeling parameters:
  • anchor_column (str): The column in which the names of new items are stored.

  • new_events (dict): Mapping of new values based on values in the original row.

  • remove_parent_row (bool): If true, the original row that was split is removed.

Methods

hed.tools.remodeling.operations.split_rows_op.SplitRowsOp.__init__(...)

Constructor for the split rows operation.

hed.tools.remodeling.operations.split_rows_op.SplitRowsOp.check_parameters(...)

Verify that the parameters meet the operation specification.

hed.tools.remodeling.operations.split_rows_op.SplitRowsOp.do_op(...)

Split a row representing a particular event into multiple rows.

Attributes

hed.tools.remodeling.operations.split_rows_op.SplitRowsOp.PARAMS

SplitRowsOp.__init__(parameters)[source]

Constructor for the split rows 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.

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

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

Split a row representing a particular event into multiple rows.

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:

TypeError – -If bad onset or duration.

SplitRowsOp.PARAMS = {'operation': 'split_rows', 'optional_parameters': {}, 'required_parameters': {'anchor_column': <class 'str'>, 'new_events': <class 'dict'>, 'remove_parent_row': <class 'bool'>}}