SplitRowsOp

class SplitRowsOp(parameters)[source]

Split rows in a columnar file with onset and duration columns into multiple rows based on a specified column.

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.

Notes

  • In specifying onset and duration for the new row, you can give values or the names of columns as strings.

Methods

SplitRowsOp.__init__(parameters)

Constructor for the split rows operation.

SplitRowsOp.do_op(dispatcher, df, name[, ...])

Split a row representing a particular event into multiple rows.

SplitRowsOp.validate_input_data(parameters)

Additional validation required of operation parameters not performed by JSON schema validator.

Attributes

SplitRowsOp.NAME

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.

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.

static SplitRowsOp.validate_input_data(parameters)[source]

Additional validation required of operation parameters not performed by JSON schema validator.

SplitRowsOp.NAME = 'split_rows'
SplitRowsOp.PARAMS = {'additionalProperties': False, 'properties': {'anchor_column': {'description': 'The column containing the keys for the new rows. (Original rows will have own keys.)', 'type': 'string'}, 'new_events': {'description': 'A map describing how the rows for the new codes will be created.', 'minProperties': 1, 'patternProperties': {'.*': {'additionalProperties': False, 'properties': {'copy_columns': {'description': 'List of columns whose values to copy for the new row.', 'items': {'type': 'string'}, 'minItems': 1, 'type': 'array', 'uniqueItems': True}, 'duration': {'description': 'List of items to add to compute the duration of the new row.', 'items': {'type': ['string', 'number']}, 'minItems': 1, 'type': 'array'}, 'onset_source': {'description': 'List of items to add to compute the onset time of the new row.', 'items': {'type': ['string', 'number']}, 'minItems': 1, 'type': 'array'}}, 'required': ['onset_source', 'duration'], 'type': 'object'}}, 'type': 'object'}, 'remove_parent_row': {'description': 'If true, the row from which these rows were split is removed, otherwise it stays.', 'type': 'boolean'}}, 'required': ['anchor_column', 'new_events', 'remove_parent_row'], 'type': 'object'}