Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi committed Nov 7, 2024
1 parent 1e0d4ae commit ebf4321
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions narwhals/_arrow/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,18 @@ def rank(
import pyarrow as pa # ignore-banned-import
import pyarrow.compute as pc # ignore-banned-import

sort_keys = "descending" if descending else "ascending"
tiebreaker = "first" if method == "ordinal" else method
native_series = self._native_series
null_mask = pc.is_null(native_series)
if method != "average":
sort_keys = "descending" if descending else "ascending"
tiebreaker = "first" if method == "ordinal" else method
native_series = self._native_series
null_mask = pc.is_null(native_series)

rank = pc.rank(native_series, sort_keys=sort_keys, tiebreaker=tiebreaker)
rank = pc.rank(native_series, sort_keys=sort_keys, tiebreaker=tiebreaker)

result = pc.if_else(null_mask, pa.scalar(None), rank)
return self._from_native_series(result)
result = pc.if_else(null_mask, pa.scalar(None), rank)
return self._from_native_series(result)
else:
pass

def __iter__(self: Self) -> Iterator[Any]:
yield from self._native_series.__iter__()
Expand Down

0 comments on commit ebf4321

Please sign in to comment.