[SPARK-58971][PS] Add pct, na_option, and axis parameters to Series.rank and DataFrame.rank - #58249
Closed
jzhan-2026 wants to merge 2 commits into
Closed
[SPARK-58971][PS] Add pct, na_option, and axis parameters to Series.rank and DataFrame.rank#58249jzhan-2026 wants to merge 2 commits into
jzhan-2026 wants to merge 2 commits into
Conversation
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.
What changes were proposed in this pull request?
Add
na_option,pct, andaxisparameters toSeries.rank(), andna_optionandpcttoDataFrame.rank(), to match the pandas API.na_option('keep'/'top'/'bottom'): controls howNaNvalues are rankedpct: expresses ranks as percentile fractions in(0, 1]axisonSeries.rank(): accepts0/'index'only, added for API compatibilityWhy are the changes needed?
The pandas-on-Spark implementations were missing these parameters, making it harder to migrate
pandas code to Spark without modification.
DataFrame.rankwas tracked in SPARK-46167; this PRalso covers
Series.rank.Does this PR introduce any user-facing change?
Yes. Two new keyword parameters on
Series.rank()andDataFrame.rank(). Defaults areunchanged so existing code is unaffected.
How was this patch tested?
New test method test_rank_pct_na_option in test_compute.py and new cases in test_stat.py
covering all methods, both axes, combined parameters, and invalid input errors.
Was this patch authored or co-authored using generative AI tooling?
This patch was co-authored with AI assistance (Claude Sonnet 4.6).