Skip to content

[Repo Assist] Add Frame.renameCol and Frame.renameColsUsing module functions (Closes #62)#603

Merged
dsyme merged 6 commits intomasterfrom
repo-assist/improve-frame-renamecol-2026-03-09-cb8e9acddba72d03
Mar 12, 2026
Merged

[Repo Assist] Add Frame.renameCol and Frame.renameColsUsing module functions (Closes #62)#603
dsyme merged 6 commits intomasterfrom
repo-assist/improve-frame-renamecol-2026-03-09-cb8e9acddba72d03

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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

🤖 This is an automated PR from Repo Assist.

Adds two non-mutating module-level functions to address the decade-old feature request in #62.

Root Cause / Motivation

df.RenameColumn(oldKey, newKey) and df.RenameColumns(mapping) are only available as mutating members. There were no functional (pipe-friendly) module equivalents. This is an inconsistency with other Frame module functions like addCol, dropCol, replaceCol, and indexColsWith.

Changes

Two new functions added to FrameModule.fs:

// Rename a single column by key
let renamed = df |> Frame.renameCol "OldName" "NewName"

// Rename all columns via a mapping function
let lower = df |> Frame.renameColsUsing (fun k -> k.ToLowerInvariant())

Both follow the same pure-construction pattern as indexColsWith — creating a new Frame directly without Clone+mutate — so no intermediate allocation is needed.

Function Description
Frame.renameCol oldKey newKey Renames one column; if oldKey is not found, the frame is returned unchanged
Frame.renameColsUsing mapping Renames all columns by applying a mapping function; changes the column key type

Note: Frame.indexColsWith already covers the case of replacing all column keys with a new sequence. The two new functions complement it by supporting single-column rename and function-based renaming.

Test Status

✅ All 468 tests pass (dotnet test tests/Deedle.Tests/Deedle.Tests.fsproj -c Release).

4 new tests cover:

  • single-column rename
  • rename with an unknown key (no-op)
  • renameColsUsing transforms all keys
  • immutability (original frame is not mutated)

Trade-offs

  • renameColsUsing changes the column key type (e.g., string -> int), consistent with indexColsWith. This is intentional and matches the member RenameColumns(mapping).
  • renameCol returns the frame unchanged when oldKey is not found, matching the silent no-op behaviour of the underlying member.

Closes #62

Generated by Repo Assist ·

To install this agentic workflow, run

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

Adds two non-mutating module-level functions to FrameModule.fs
to address the long-standing issue #62:

- Frame.renameCol oldKey newKey: renames a single column by matching
  the old key; if the key is not found, the frame is returned unchanged.
- Frame.renameColsUsing mapping: renames all columns by applying a
  mapping function.

Both functions follow the same pure construction pattern as
Frame.indexColsWith (creating a new Frame directly without Clone+mutate).

Four tests added; all 468 tests pass.

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

dsyme commented Mar 9, 2026

/repo-assist update the new xmldoc comments to be proper xml doc comments like the others

…XML format

Convert Markdown-style doc comments (## Parameters, [category:...]) to proper
XML doc comment format (<summary>, <param>, <category>) consistent with the
rest of FrameModule.fs.

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

github-actions Bot commented Mar 9, 2026

Commit pushed: f147d6d

Generated by Repo Assist

@dsyme dsyme merged commit e4191a0 into master Mar 12, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/improve-frame-renamecol-2026-03-09-cb8e9acddba72d03 branch March 12, 2026 02:19
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.

Add Frame.foo version of df.RenameSeries

1 participant