Commit 81e8678
[SPARK-56187][PS] Fix Series.argsort null ordering for pandas 3
### What changes were proposed in this pull request?
This PR updates pandas-on-Spark `Series.argsort()` to follow the pandas 3 behavior for null values.
Before this change, `Series.argsort()` always dropped nulls from the ordering step and appended `-1` for null positions. That matches pandas 2 behavior, but it no longer matches pandas 3, where nulls are ordered last and receive real positional indices.
This patch keeps the existing pandas `< 3.0.0` behavior, including the deprecation warning, and switches pandas `>= 3.0.0` to sort the full Series with nulls ordered last so the returned positions match upstream pandas.
### Why are the changes needed?
`pyspark.pandas.tests.series.test_arg_ops SeriesArgOpsTests.test_argsort` fails in the pandas 3 environment because pandas-on-Spark still implements the deprecated pandas 2 null-handling semantics.
For example, with null values present:
- pandas 3 returns positional indices for all rows, with nulls ordered last
- pandas-on-Spark returned `-1` for null rows
This makes `Series.argsort()` inconsistent with pandas 3 and causes the existing compatibility test to fail.
### Does this PR introduce _any_ user-facing change?
Yes, it will behave more like pandas 3.
### How was this patch tested?
The existing tests should pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)
Closes #54989 from ueshin/issues/SPARK-56187/argsort.
Authored-by: Takuya Ueshin <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>1 parent ab2a069 commit 81e8678
1 file changed
+25
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6422 | 6422 | | |
6423 | 6423 | | |
6424 | 6424 | | |
6425 | | - | |
6426 | | - | |
6427 | | - | |
6428 | | - | |
6429 | | - | |
6430 | | - | |
| 6425 | + | |
| 6426 | + | |
| 6427 | + | |
| 6428 | + | |
| 6429 | + | |
| 6430 | + | |
| 6431 | + | |
| 6432 | + | |
| 6433 | + | |
6431 | 6434 | | |
6432 | | - | |
| 6435 | + | |
6433 | 6436 | | |
6434 | 6437 | | |
6435 | 6438 | | |
| |||
6446 | 6449 | | |
6447 | 6450 | | |
6448 | 6451 | | |
6449 | | - | |
6450 | | - | |
| 6452 | + | |
| 6453 | + | |
6451 | 6454 | | |
6452 | 6455 | | |
6453 | 6456 | | |
| |||
6463 | 6466 | | |
6464 | 6467 | | |
6465 | 6468 | | |
6466 | | - | |
6467 | | - | |
6468 | | - | |
| 6469 | + | |
| 6470 | + | |
| 6471 | + | |
| 6472 | + | |
| 6473 | + | |
| 6474 | + | |
6469 | 6475 | | |
6470 | 6476 | | |
6471 | 6477 | | |
| |||
6492 | 6498 | | |
6493 | 6499 | | |
6494 | 6500 | | |
6495 | | - | |
6496 | | - | |
6497 | | - | |
6498 | | - | |
| 6501 | + | |
| 6502 | + | |
| 6503 | + | |
| 6504 | + | |
| 6505 | + | |
| 6506 | + | |
| 6507 | + | |
6499 | 6508 | | |
6500 | 6509 | | |
6501 | 6510 | | |
| |||
0 commit comments