BUG: Fix problems in group rank when both nans and infinity are present #20561
State: closed

Please include the output of the validation script below between the "```" ticks:

```

################################################################################
############# Docstring (pandas._libs.groupby.group_rank_float64)  #############
################################################################################

Provides the rank of values within each group

Parameters
----------
out : array of float64_t values which this method will write its results to
values : array of float64_t values to be ranked
labels : array containing unique label for each group, with its ordering
    matching up to the corresponding record in `values`
is_datetimelike : bool
    unused in this method but provided for call compatibility with other
    Cython transformations
ties_method :  {'keep', 'top', 'bottom'}
    * keep: leave NA values where they are
    * top: smallest rank if ascending
    * bottom: smallest rank if descending
ascending : boolean
    False for ranks by high (1) to low (N)
pct : boolean
    Compute percentage rank of data within each group

Notes
-----
This method modifies the `out` parameter rather than returning an object

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
        Docstring text (summary) should start in the line immediately after the opening quotes (not in the same line, or leaving a blank line in between)
        Summary does not end with dot
        No extended summary found
        Errors in parameters section
                Unknown parameters {'values', 'pct', 'labels', 'out', 'ties_method', 'ascending', 'is_datetimelike'}
                Parameter "out" has no description
                Parameter "values" has no description
                Parameter "labels" description should start with capital letter
                Parameter "labels" description should finish with "."
                Parameter "is_datetimelike" description should start with capital letter
                Parameter "is_datetimelike" description should finish with "."
                Parameter "ties_method" description should start with capital letter
                Parameter "ties_method" description should finish with "."
                Parameter "ascending" description should finish with "."
                Parameter "pct" description should finish with "."
        No returns section found
        See Also section not found
        No examples section found

```

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

- [x] closes #20561
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Bug
name: Groupby
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20681?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@7e75e4a`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/20681/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/20681?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #20681   +/-   ##
=========================================
  Coverage          ?   91.84%           
=========================================
  Files             ?      153           
  Lines             ?    49295           
  Branches          ?        0           
=========================================
  Hits              ?    45274           
  Misses            ?     4021           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.23% <ø> (?)` | |
| #single | `41.89% <ø> (?)` | |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20681?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20681?src=pr&el=footer). Last update [7e75e4a...6eb1d8f](https://codecov.io/gh/pandas-dev/pandas/pull/20681?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

pls rebase as well.
cc @WillAyd if you could review
Need to fix conflict with whatsnew merge but otherwise lgtm. Thanks for opening the other issues
thanks @peterpanmj and @WillAyd nice patches!

keep em coming both of you!