SelectColumns

SelectColumns keeps a comma-separated list of columns and optionally renames them. It is useful before reports, exports, or joins that need a compact table shape.

Inputs

  • upstream table: pandas DataFrame from a previous table tool.

  • columns: comma-separated list in output order.

  • rename_mapping: optional comma-separated old:new entries.

Outputs

The output is a DataFrame containing the selected columns, with optional renames applied.

Minimal Example

from bioimageflow_core import Arguments
from bioimageflow_common_tools import SelectColumns

selected = SelectColumns().transform(
    df,
    Arguments(columns="sample,score", rename_mapping="score:value"),
)

Dependencies and Core Libraries

pandas.

Assumptions

All selected columns exist in the upstream table. Rename mappings must refer to selected columns.

Expected Results

The output table contains only the selected columns, in the requested order, with requested renames applied.

Failure Modes

Missing selected columns raise KeyError. Malformed rename mappings raise ValueError.