ReorderColumnsOp¶
- class ReorderColumnsOp(parameters)[source]
Reorder columns in a tabular file.
- Required parameters:
column_order (list): The names of the columns to be reordered.
ignore_missing (bool): If false and a column in column_order is not in df, skip the column
keep_others (bool): If true, columns not in column_order are placed at end.
Methods
|
Constructor for reorder columns operation. |
|
Verify that the parameters meet the operation specification. |
|
Reorder columns as specified in event dictionary. |
Attributes
|
- ReorderColumnsOp.__init__(parameters)[source]¶
Constructor for reorder 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.
- ReorderColumnsOp.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.
- ReorderColumnsOp.do_op(dispatcher, df, name, sidecar=None)[source]¶
Reorder columns as specified in event dictionary.
- 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:
ValueError –
When ignore_missing is false and column_order has columns not in the data.
- ReorderColumnsOp.PARAMS = {'operation': 'reorder_columns', 'optional_parameters': {}, 'required_parameters': {'column_order': <class 'list'>, 'ignore_missing': <class 'bool'>, 'keep_others': <class 'bool'>}}¶