Skip to content

[Repo Assist] Add iloc integer-position indexing for Frame and Series#631

Merged
dsyme merged 2 commits intomasterfrom
repo-assist/fix-issue-444-iloc-5dd521fea65a202f
Mar 17, 2026
Merged

[Repo Assist] Add iloc integer-position indexing for Frame and Series#631
dsyme merged 2 commits intomasterfrom
repo-assist/fix-issue-444-iloc-5dd521fea65a202f

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated PR from Repo Assist.

Closes #444

Summary

Implements iloc-style integer-position based indexing for both Series and Frame, equivalent to the pandas iloc accessor.

New API

Series.iloc

// Select elements at positions 0, 2, 4
let s = series [ "a" => 10; "b" => 20; "c" => 30; "d" => 40; "e" => 50 ]
s |> Series.iloc [0; 2; 4]
// → series [ "a" => 10; "c" => 30; "e" => 50 ]

Original keys are preserved.

Frame.ilocRows

// Select rows at positions 0 and 2
df |> Frame.ilocRows [0; 2]

Frame.ilocCols

// Select columns at positions 0 and 2
df |> Frame.ilocCols [0; 2]

Frame.iloc

// Select rows 1, 2, 3 and columns 1, 2 (equivalent to pandas iloc[1:4, 1:3])
df |> Frame.iloc [1; 2; 3] [1; 2]

Implementation

All four functions resolve integer positions to the underlying keys using the existing GetRowKeyAt / ColumnIndex.KeyAt methods, then delegate to frame.Rows.[keys] / frame.Columns.[keys] / series.GetItems(keys). This keeps the implementation minimal and leverages battle-tested code paths.

The functions are also compiled under PascalCase names (Iloc, IlocRows, IlocCols) so they are usable from C#.

Test Status

✅ 7 new tests added in Frame.fs and Series.fs
✅ All 595 tests pass (dotnet test tests/Deedle.Tests/Deedle.Tests.fsproj -c Release)

Generated by Repo Assist for issue #444 ·

To install this agentic workflow, run

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

Implements iloc-style integer-position based indexing for both
Series and Frame, addressing #444.

New functions:
- Series.iloc (positions: seq<int>) : Series<'K,'T> -> Series<'K,'T>
  Returns a series with elements at the given integer positions,
  preserving the original keys.

- Frame.ilocRows (rowPositions: seq<int>) : Frame<'R,'C> -> Frame<'R,'C>
  Returns a frame with only the rows at the given integer positions.

- Frame.ilocCols (colPositions: seq<int>) : Frame<'R,'C> -> Frame<'R,'C>
  Returns a frame with only the columns at the given integer positions.

- Frame.iloc (rowPositions: seq<int>) (colPositions: seq<int>) : Frame<'R,'C> -> Frame<'R,'C>
  Returns a sub-frame selecting both rows and columns by position,
  equivalent to pandas DataFrame.iloc[rows, cols].

All four functions are also exposed as compiled names (Iloc, IlocRows,
IlocCols) for C# consumers. 7 new tests added; all 595 tests pass.

Co-authored-by: Copilot <[email protected]>
This was referenced Mar 17, 2026
@dsyme dsyme marked this pull request as ready for review March 17, 2026 00:45
@dsyme dsyme merged commit c3734e5 into master Mar 17, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-444-iloc-5dd521fea65a202f branch March 17, 2026 00: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.

iloc method.

1 participant