Conversation
Implements the feature requested in issue #372 (dense rank / ntile). - Series.rank: 1-based dense rank using default comparison; ties share same rank - Series.rankWith: dense rank with a custom comparison function - Series.ntile: divides values into N equal-sized buckets (0-based) - Frame.rankRowsBy: rank frame rows by a named column (returns a Series) - C# extension methods for all three Series operations and Frame.RankRowsBy - Tests covering basic rank, ties, missing values, custom comparator, ntile with even and uneven bucket sizes, and adding a rank column to a frame Co-authored-by: Copilot <[email protected]>
This was referenced Mar 17, 2026
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.
🤖 Repo Assist — automated PR implementing the feature requested in issue #372.
Closes #372
What this adds
Series.rankSeries.rankWithSeries.ntile nnequal-sized buckets numbered0 … n-1. Earlier buckets get one extra element when not evenly divisible.Frame.rankRowsBy colKeySeries(rowKey, int).C# extension methods (
Rank,RankWith,Ntile,RankRowsBy) are provided in the corresponding*Extensions.fsfiles.Usage examples
Design notes
Series.rankusesMap<'V, int>for O(n log n) lookup.Series.rankWithwalks a sorted array; lookup is O(n) per element (acceptable for typical series sizes; the common numeric use-case should useSeries.rank).Series.ntilesorts by value viaSeq.sortBy sndonobservations, so only present values are bucketed.Test status
All 616 existing tests pass. Eight new tests were added:
Series.fs: rank basic, rank with ties, rank with missing values, rank with custom comparator, ntile equal buckets, ntile uneven bucketsFrame.fs: rank rows by column, rank and add as column