Skip to main content

metric_frame

Shared scan-metrics frame assembly.

assemble_scan_frame is the merge-and-tag loop that both criteria_matching and biomarker_tabulation route their scan-metrics frames through: each already-built metrics frame is left-merged onto a base frame by a shared key, colliding columns are coalesced rather than suffixed, and every merged column is tagged CriterionProvenance.SCAN.

Module

Functions

assemble_scan_frame

def assemble_scan_frame(    base: pandas.core.frame.DataFrame,    scan_frames: collections.abc.Sequence[pandas.core.frame.DataFrame],    *,    key: str = '_original_filename',)> tuple[pandas.core.frame.DataFrame, dict[str, CriterionProvenance]]:

Left-merge each non-empty scan frame onto base, tagging SCAN provenance.

Shared scan-metrics merge loop used by both criteria_matching and biomarker_tabulation. Each already-built metrics frame (e.g. one per GA/fluid/CST/GCC producer) is merged in turn: colliding columns are coalesced via _drop_colliding_columns rather than suffixed, so a left-merge cannot silently orphan a criterion's target column.

Arguments

  • base: The frame being merged onto (already carries the merge key).
  • scan_frames: Already-built per-source metrics frames to merge in, in order; a frame with no rows is skipped. Each frame must hold at most one row per key value — the left-merge fans base's rows out on a duplicate key. Every current builder satisfies this (cache file_id is unique per partition; backfill_metrics keys by filename), so the precondition is not re-checked here.
  • key: The shared merge key column.

Returns (merged_df, column_provenance)base with every non-empty scan_frames entry merged in, and a {column: CriterionProvenance.SCAN} map covering every column each merged-in frame contributed (after collision coalescing).