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 mergekey).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 perkeyvalue — the left-merge fansbase's rows out on a duplicate key. Every current builder satisfies this (cachefile_idis unique per partition;backfill_metricskeys 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).