Skip to content

Commit 78ee555

Browse files
authored
CLN: Remove special case for rank in groupby.ops (#46953)
* CLN: Remove special case for rank in groupby.ops * Remove TODO
1 parent d42a148 commit 78ee555

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

pandas/_libs/groupby.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,8 +1325,8 @@ def group_rank(
13251325
mask=sub_mask,
13261326
)
13271327
for i in range(len(result)):
1328-
# TODO: why can't we do out[:, k] = result?
1329-
out[i, k] = result[i]
1328+
if labels[i] >= 0:
1329+
out[i, k] = result[i]
13301330

13311331

13321332
# ----------------------------------------------------------------------

pandas/core/groupby/ops.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,6 @@ def _call_cython_op(
623623

624624
result = result.T
625625

626-
if self.how == "rank" and self.has_dropped_na:
627-
# TODO: Wouldn't need this if group_rank supported mask
628-
result = np.where(comp_ids < 0, np.nan, result)
629-
630626
if self.how not in self.cast_blocklist:
631627
# e.g. if we are int64 and need to restore to datetime64/timedelta64
632628
# "rank" is the only member of cast_blocklist we get here

0 commit comments

Comments
 (0)