anshulbaliga7 opened a new pull request, #60221:
URL: https://github.com/apache/spark/pull/60221

   ### What changes were proposed in this pull request?
   
   This PR makes `Series.rank` raise `ValueError("Series does not support 
columns axis.")` for `axis=1` or `axis='columns'`, as the other `Series` 
methods that take an `axis` parameter do (for example `Series.filter` and 
`Series.align`).
   
   SPARK-58971 (#58254) added the `axis` parameter to `Series.rank` but only 
called `validate_axis(axis)` and discarded its result. `validate_axis` returns 
`1` for `axis=1` or `axis='columns'` without raising, so the value was silently 
ignored and the Series was ranked along the index.
   
   ### Why are the changes needed?
   
   pandas raises for a `Series` on the columns axis, and the docstring already 
documents `axis : {0 or 'index'}`:
   
   ```python
   >>> pd.Series([1, 2]).rank(axis=1)
   ValueError: No axis named 1 for object type Series
   ```
   
   Before this PR, pandas-on-Spark returned the index-wise ranks instead.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. SPARK-58971 is not released yet, and `Series.rank` did not accept `axis` 
before it.
   
   ### How was this patch tested?
   
   New assertions in `test_rank` of `pyspark.pandas.tests.series.test_stat`: 
`axis=1` and `axis='columns'` raise `ValueError`, an unknown axis still raises 
`No axis named`, and `axis='index'` keeps matching pandas.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude claude-opus-4-8


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to