Skip to content

[Repo Assist] Add Frame.compare — column-by-column frame diffing (closes #9)#637

Merged
dsyme merged 5 commits intomasterfrom
repo-assist/fix-issue-9-frame-compare-192c3e83c1fde656
Mar 18, 2026
Merged

[Repo Assist] Add Frame.compare — column-by-column frame diffing (closes #9)#637
dsyme merged 5 commits intomasterfrom
repo-assist/fix-issue-9-frame-compare-192c3e83c1fde656

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist in response to a /repo-assist command from @dsyme.

Closes #9.

What

Adds Frame.compare — the frame-level counterpart to the already-existing Series.compare. Given two frames, Frame.compare returns a new Frame<'R, 'C> where each cell is a Diff(obj) describing the change between the two frames.

let df1 = frame [ "A" =?> series [ 1 => 1.0; 2 => 2.0; 3 => 3.0 ]
                  "B" =?> series [ 1 => 10.0; 2 => 20.0 ] ]
let df2 = frame [ "A" =?> series [ 1 => 99.0; 2 => 2.0; 4 => 4.0 ]
                  "C" =?> series [ 1 => 100.0 ] ]

let diff = Frame.compare df1 df2
// Column "A": key 1 → Change(1.0, 99.0); key 2 → (omitted, unchanged); key 3 → Remove 3.0; key 4 → Add 4.0
// Column "B": all rows → Remove (column only in df1)
// Column "C": all rows → Add   (column only in df2)

Approach

  • Root cause: Frame.compare was never implemented, even though Series.compare and the Diff<'T> type have existed for a while.
  • Fix: In FrameModule.fs, iterate over the union of both frames' column keys, retrieve each column as Series<'R, obj> (using TryGetColumn(obj) — columns missing from one frame yield Series.empty), then delegate per-column comparison to the existing Series.compare / series.Compare(). The result columns are collected into a new frame via FrameUtils.fromColumns.
  • Why not a Frame member? Adding Compare directly to the Frame<'R,'C> type body (which uses F#'s mutually-recursive and with FrameUtils) caused type-inference issues that constrained FrameUtils.fromColumns to obj, breaking unrelated code. Implementing it as a standalone function in FrameModule.fs avoids this entirely, consistent with how strConcat and zip are structured.

Test status

All 615 existing tests pass. Three new tests cover:

  1. Detecting Change, Remove, and Add values in shared columns
  2. Columns present in only one frame
  3. Identical frames producing empty diff columns

Generated by Repo Assist for issue #9 ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

Implements the frame-comparison part of #9. Given two frames, Frame.compare
returns a new frame where each cell is a Diff<obj> describing whether the
value was unchanged (omitted), changed (Change), removed (Remove), or added
(Add) relative to the first frame.

- Columns present only in frame1 yield Diff.Remove values
- Columns present only in frame2 yield Diff.Add values
- Columns present in both are compared element-wise via Series.compare

Series.compare already existed; this adds the Frame-level counterpart.

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 17, 2026 01:27
@dsyme
Copy link
Copy Markdown
Member

dsyme commented Mar 18, 2026

/repo-assist add some testing that is not type Diff, we need to check the strong typing works

@dsyme dsyme closed this Mar 18, 2026
@dsyme dsyme reopened this Mar 18, 2026
…parisons

Add tests that use explicit type annotations (Series<int, Diff<float>>,
Series<string, Diff<string>>, Series<string, Diff<int>>) to verify
Series.compare and Series.Compare are strongly typed — not Diff<obj>.
Also add Frame column strong-typing tests using Series.compare on
typed columns extracted from frames.

Co-authored-by: Copilot <[email protected]>
@github-actions
Copy link
Copy Markdown
Contributor Author

Commit pushed: 96b3a27

Generated by Repo Assist

@dsyme dsyme merged commit f120653 into master Mar 18, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-9-frame-compare-192c3e83c1fde656 branch March 18, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diff data frames/series

1 participant