Conversation
Adds a new Frame.distinctRowsBy function that retains only the first row for each unique combination of values in the specified columns. This is analogous to SQL 'SELECT DISTINCT col1, col2' — a commonly requested feature (see issue #558). Also adds a C#-friendly DistinctRowsBy extension method that accepts a params array of column keys. Includes three unit tests for: partial deduplication, no-op on already-distinct data, and full deduplication. Co-authored-by: Copilot <[email protected]>
This was referenced Mar 9, 2026
Member
|
/repo-assist update the added xmldoc comment to be proper xmldoc style |
Use <summary>, <param>, and <category> tags matching the existing xmldoc conventions in FrameExtensions.fs. Co-authored-by: Copilot <[email protected]>
Contributor
Author
|
Commit pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds
Frame.distinctRowsBy, a new frame-transformation function that retains only the first row (by index order) for each unique combination of values in the specified columns.This is analogous to SQL
SELECT DISTINCT col1, col2 FROM table— a pattern that comes up regularly (see #558).Example
C#:
Implementation
distinctRowsByis built on top of the existingfilterRowsprimitive. For each row, it computes a key as anobj listof the requested column values. F# lists have structural equality andGetHashCode()soHashSet(obj list)correctly deduplicates any combination of standard .NET value types (strings, ints, floats, DateTime, etc.).A C#-friendly
[(Extension)] DistinctRowsBy(frame, [(ParamArray)] columns)overload is added toFrameExtensions.Test Status
src/Deedle/Deedle.fsproj— builds without errors ✅tests/Deedle.Tests/Deedle.Tests.fsproj— compiles without errors ✅Trade-offs
obj listkey rather than a typed tuple — keeps the implementation simple and avoids arity limits, at the cost of boxing value types per row per call. For large frames with many unique columns, a customIEqualityComparercould improve performance, but this is sufficient for typical use.nullin the key (two rows with missing values in the same columns are considered equal).