Skip to content

[Repo Assist] Add boolean mask indexing: Series.filterByMask, Frame.filterRowsByMask, Frame.filterColsByMask (Closes #318)#619

Merged
dsyme merged 3 commits intomasterfrom
repo-assist/fix-issue-318-boolean-mask-indexing-f48ae036891543e7
Mar 14, 2026
Merged

[Repo Assist] Add boolean mask indexing: Series.filterByMask, Frame.filterRowsByMask, Frame.filterColsByMask (Closes #318)#619
dsyme merged 3 commits intomasterfrom
repo-assist/fix-issue-318-boolean-mask-indexing-f48ae036891543e7

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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

Summary

Adds pandas-style boolean mask indexing to Deedle, addressing the long-standing feature request in #318.

Closes #318.

New Functions

Series.filterByMask

// Filter a series using a boolean mask series
let s = series [ "a" => 1.0; "b" => 2.0; "c" => 3.0; "d" => 4.0 ]
let mask = series [ "a" => true; "b" => false; "c" => true; "d" => false ]
let result = s |> Series.filterByMask mask
// result: series [ "a" => 1.0; "c" => 3.0 ]

Frame.filterRowsByMask

// Filter frame rows using a boolean Series<'R, bool>
let adults = df.GetColumn(int)("Age") |> Series.mapValues (fun age -> age >= 18)
let filtered = df |> Frame.filterRowsByMask adults

Frame.filterColsByMask

// Filter frame columns using a boolean Series<'C, bool>
let wantedCols = series [ "A" => true; "B" => false; "C" => true ]
let filtered = df |> Frame.filterColsByMask wantedCols

All three functions exclude keys missing from the mask (treated as false).

Design Notes

  • Composable: works naturally with Series.mapValues, Series.map, or any expression that produces a Series<'K, bool>
  • Missing-safe: mask entries with OptionalValue.Missing are treated as false
  • Consistent with existing API: follows the same conventions as filterRows, filterValues, etc.
  • C# compatible: [(CompiledName)] attributes provide idiomatic PascalCase names: FilterByMask, WhereRowsByMask, WhereColsByMask

Test Status

7 new tests added, all 501 tests pass (previously 494 tests).

Tests cover:

  • Filtering series by mask (all true, mixed, all false)
  • Filtering with mask that has fewer keys than the series
  • Filtering frame rows by mask
  • Filtering frame columns by mask
  • Derived boolean mask from column predicate (the idiomatic pandas-style usage)

Generated by Repo Assist ·

To install this agentic workflow, run

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

…k, Frame.filterColsByMask

Closes #318

Adds pandas-style boolean mask indexing functions:
- Series.filterByMask: filter a series by a boolean mask series
- Frame.filterRowsByMask: filter frame rows using a boolean Series<'R, bool>
- Frame.filterColsByMask: filter frame columns using a boolean Series<'C, bool>

Keys missing from the mask are excluded (treated as false).

Typical usage:
  let adults = df.GetColumn<int>("Age") |> Series.mapValues (fun age -> age >= 18)
  let filtered = df |> Frame.filterRowsByMask adults

7 new tests added; all 501 tests pass.

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 14, 2026 00:34
@dsyme dsyme merged commit 79e0977 into master Mar 14, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-318-boolean-mask-indexing-f48ae036891543e7 branch March 14, 2026 00:42
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 something akin to boolean indexing from Pandas

1 participant