Skip to content

[Repo Assist] Fix Frame.indexRowsWith to produce missing values for extra row keys#595

Merged
dsyme merged 5 commits intomasterfrom
repo-assist/fix-issue-498-indexrowswith-extra-keys-15abd25a49fa86a1
Mar 9, 2026
Merged

[Repo Assist] Fix Frame.indexRowsWith to produce missing values for extra row keys#595
dsyme merged 5 commits intomasterfrom
repo-assist/fix-issue-498-indexrowswith-extra-keys-15abd25a49fa86a1

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

Fixes Frame.indexRowsWith to correctly handle the case where the caller provides more row keys than the frame currently has rows. Extra keys now produce rows with missing values, consistent with user expectations.

Closes #498


Root Cause

indexRowsWith built a VectorConstruction.GetRange command that always spanned the original row range. When the caller supplied a longer key sequence the new RowIndex had more entries than the resulting data vectors (length = original row count), producing an internally inconsistent frame. Downstream operations like Frame.fillMissingWith either silently no-opped or threw:

System.InvalidOperationException: Index and vector of a series should have the same length!

Fix

When newCount > existingCount, the vector command is changed to:

VectorConstruction.Append(existing, VectorConstruction.Empty(newCount - existingCount))

This appends an all-missing segment so the vector length matches the new row index. When newCount <= existingCount the original behaviour is preserved.

An empty-frame edge-case (existingCount = 0) is handled with VectorConstruction.Empty newCount.

Trade-offs

  • No API changeindexRowsWith accepts the same arguments as before; only the output for longer key sequences changes from "broken frame" to "frame with missing rows".
  • indexColsWith already validates that key count must equal column count; indexRowsWith now has richer semantics (pad with missing) instead of strict validation, matching the reasonable user expectation demonstrated in Frame.fillMissing does not work with Frame.indexRowsWith #498.

Test Status

A regression test was added in tests/Deedle.Tests/Frame.fs that:

  • verifies RowCount is the new key count
  • checks that extra rows have missing values
  • confirms fillMissingWith 0.0 fills the extra rows correctly
  • confirms original rows are unchanged

Build:dotnet build src/Deedle/Deedle.fsproj -c Release — succeeded, 0 errors
Test compile:dotnet build tests/Deedle.Tests/Deedle.Tests.fsproj -c Release — succeeded, 0 errors
Test run: ⚠️ Not runnable locally — the test project targets net5.0 but only .NET 8+ is available in this environment. CI (once PR #590 upgrading to .NET 8 lands) will run the full test suite.

Generated by Repo Assist ·

To install this agentic workflow, run

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

…#498)

When Frame.indexRowsWith receives more keys than the frame has rows,
the extra rows are now properly represented as missing values.

Previously the function produced a frame with an inconsistent state:
the row index had more entries than the data vectors, causing
Frame.fillMissingWith to silently no-op (for non-float types) or throw
an InvalidOperationException (for float).

Root cause: VectorConstruction.GetRange always spanned the original row
range, leaving the new index longer than the resulting vector.

Fix: when newCount > existingCount, append a VectorConstruction.Empty
block (all-missing) for the extra rows so the vector length matches the
new index length.

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 9, 2026 04:05
@dsyme dsyme merged commit f846932 into master Mar 9, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-498-indexrowswith-extra-keys-15abd25a49fa86a1 branch March 9, 2026 12:45
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.

Frame.fillMissing does not work with Frame.indexRowsWith

1 participant