Skip to content

[Repo Assist] Add Frame.meltBy for pandas-style melt with identity columns#598

Merged
dsyme merged 6 commits intomasterfrom
repo-assist/improve-melt-by-idcols-554-16a28da0a3a2db9d
Mar 12, 2026
Merged

[Repo Assist] Add Frame.meltBy for pandas-style melt with identity columns#598
dsyme merged 6 commits intomasterfrom
repo-assist/improve-melt-by-idcols-554-16a28da0a3a2db9d

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Mar 9, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds Frame.meltBy, a new frame-transformation function that keeps specified identity columns as-is and melts the remaining columns into Column/Value pairs. This is analogous to pandas DataFrame.melt(id_vars=...) and R's data.table::melt.

Closes #554.

Usage

let df =
    frame [ "ticker" =?> series [ 0 => "AAPL"; 1 => "MSFT" ]
            "price"  =?> series [ 0 => 189.5; 1 => 415.2 ]
            "volume" =?> series [ 0 => 1_200_000.0; 1 => 800_000.0 ] ]

let melted = df |> Frame.meltBy ["ticker"]
// Result:
// ticker | Column | Value
// -------+--------+----------
// AAPL   | price  | 189.5
// AAPL   | volume | 1200000.0
// MSFT   | price  | 415.2
// MSFT   | volume |  800000.0

Implementation

  • Frame.meltBy (idCols: seq<'C>) (frame: Frame<'R, 'C>) in FrameModule.fs
  • Accepts any seq<'C> of identity column keys (uses HashSet for O(1) lookup)
  • Output frame: integer row index, string column keys ([id cols...] + "Column" + "Value")
  • Preserves the original element type of each identity column via createTypedVector
  • Infers the common supertype for the Value column (same strategy as Frame.melt)

Tests

4 new tests in Frame.fs:

  • Row count is correct (rows × value_cols)
  • Output column names include id columns + Column + Value
  • Id column values are repeated correctly
  • Id column element types are preserved

Test Status

✅ Build succeeded (0 errors, 4 warnings — all pre-existing)
✅ All 468 tests pass (including 4 new meltBy tests)

Generated by Repo Assist ·

To install this agentic workflow, run

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

…554)

Adds Frame.meltBy, a new frame transformation that keeps specified identity
columns and melts the remaining columns into Column/Value pairs. This is
analogous to pandas DataFrame.melt(id_vars=...) and R data.table::melt.

- Accepts any seq<'C> of id column keys
- Outputs frame with columns: [id cols...] + Column + Value
- Preserves original type of each identity column
- Infers common supertype for value column (matching existing melt behaviour)
- Adds 4 tests covering row count, column names, id values, and type preservation

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

github-actions Bot commented Mar 9, 2026

🤖 This is an automated response from Repo Assist.

CI failure note: The build failures on this PR are not caused by the code changes here. After PR #590 upgraded fsdocs, the docs build now fails on all branches because the existing [category:] syntax in XML doc comments is no longer valid in the new fsdocs version (it expects (category)...(/category) XML elements instead).

PR #597 by @dsyme fixes this issue. Once #597 is merged to master, all open PRs (including this one) will need to be rebased to pick up the doc-syntax fix and restore green CI.

Generated by Repo Assist ·

To install this agentic workflow, run

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

@dsyme dsyme marked this pull request as ready for review March 9, 2026 13:10
@dsyme dsyme merged commit de4cacb into master Mar 12, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/improve-melt-by-idcols-554-16a28da0a3a2db9d branch March 12, 2026 02:18
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.

Change melt to have optional parameters in line with Pandas DateFrame and R's data.table

1 participant